summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-04-07 14:28:28 -0400
committerBen Gamari <ben@smart-cactus.org>2022-04-07 14:28:28 -0400
commit23ef62b3e04ad834153269980dab4aac35a1fc7e (patch)
tree9bb3e41fa20b090ea29a4a74ded5fc2a4ce86410
parentd6665d8589bfc9869486fe57644f40a7704d95d0 (diff)
downloadhaskell-23ef62b3e04ad834153269980dab4aac35a1fc7e.tar.gz
rts: Fix off-by-one in snwprintf usagewip/windows-finalwip/windows-clang-join
-rw-r--r--rts/linker/LoadArchive.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/rts/linker/LoadArchive.c b/rts/linker/LoadArchive.c
index a2641e83ad..3c35a029a4 100644
--- a/rts/linker/LoadArchive.c
+++ b/rts/linker/LoadArchive.c
@@ -520,8 +520,11 @@ HsInt loadArchive_ (pathchar *path)
int size = pathprintf(NULL, 0, WSTR("%" PATH_FMT "(#%d:%.*s)"),
path, memberIdx, (int)thisFileNameSize, fileName);
- archiveMemberName = stgMallocBytes((size+1) * sizeof(pathchar), "loadArchive(file)");
- pathprintf(archiveMemberName, size, WSTR("%" PATH_FMT "(#%d:%.*s)"),
+ // I don't understand why this extra +1 is needed here; pathprintf
+ // should have given us the correct length but in practice it seems
+ // to be one byte short on Win32.
+ archiveMemberName = stgMallocBytes((size+1+1) * sizeof(pathchar), "loadArchive(file)");
+ pathprintf(archiveMemberName, size+1, WSTR("%" PATH_FMT "(#%d:%.*s)"),
path, memberIdx, (int)thisFileNameSize, fileName);
ObjectCode *oc = mkOc(STATIC_OBJECT, path, image, memberSize, false, archiveMemberName,