Zubin pushed to branch wip/26613 at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • rts/linker/PEi386.c
    ... ... @@ -552,7 +552,12 @@ static int compare_path(StgWord key1, StgWord key2)
    552 552
     
    
    553 553
     static void addLoadedDll(LoadedDllCache *cache, const pathchar *dll_name, HINSTANCE instance)
    
    554 554
     {
    
    555
    -    insertHashTable_(cache->hash, (StgWord) dll_name, instance, hash_path);
    
    555
    +    // dll_name might be deallocated, we need to copy it to have a stable reference to the contents
    
    556
    +    // See #26613
    
    557
    +    int size = sizeof(pathchar) * wcslen(dll_name) + 1;
    
    558
    +    pathchar* dll_name_copy = stgMallocBytes(size, "addLoadedDll");
    
    559
    +    wcsncpy(dll_name_copy, dll_name, size);
    
    560
    +    insertHashTable_(cache->hash, (StgWord) dll_name_copy, instance, hash_path);
    
    556 561
     }
    
    557 562
     
    
    558 563
     static HINSTANCE isDllLoaded(const LoadedDllCache *cache, const pathchar *dll_name)