[Git][ghc/ghc][wip/26613] rts/linker/PEi386: Copy strings before they are inserted into LoadedDllCache....
Zubin pushed to branch wip/26613 at Glasgow Haskell Compiler / GHC Commits: f23c335b by Zubin Duggal at 2025-11-27T14:02:25+05:30 rts/linker/PEi386: Copy strings before they are inserted into LoadedDllCache. The original strings are temporary and might be freed at an arbitrary point. Fixes #26613 - - - - - 1 changed file: - rts/linker/PEi386.c Changes: ===================================== rts/linker/PEi386.c ===================================== @@ -552,7 +552,12 @@ static int compare_path(StgWord key1, StgWord key2) static void addLoadedDll(LoadedDllCache *cache, const pathchar *dll_name, HINSTANCE instance) { - insertHashTable_(cache->hash, (StgWord) dll_name, instance, hash_path); + // dll_name might be deallocated, we need to copy it to have a stable reference to the contents + // See #26613 + int size = sizeof(pathchar) * wcslen(dll_name) + 1; + pathchar* dll_name_copy = stgMallocBytes(size, "addLoadedDll"); + wcsncpy(dll_name_copy, dll_name, size); + insertHashTable_(cache->hash, (StgWord) dll_name_copy, instance, hash_path); } static HINSTANCE isDllLoaded(const LoadedDllCache *cache, const pathchar *dll_name) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f23c335b2347d586696a3a77f9dfa95e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f23c335b2347d586696a3a77f9dfa95e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Zubin (@wz1000)