Skip to content

Commit b00ede8

Browse files
committed
fix stack overflow caused by calling alloca in a loop
fixes #6
1 parent 0e2da05 commit b00ede8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utility.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ void ReplaceWemData(HWND window)
254254
MessageBox(window, infoMessage, "a", 0);
255255
}
256256
const char* currentPosition;
257+
char* currentFileNameBuffer = alloca(UNICODE_STRING_MAX_BYTES+1); // assuming long paths and utf-8 are enabled, this might be correct? idc
257258
for (uint32_t i = 0; i < selectedChildItemsDataList.length; i++) {
258259
if (i % nFilesSelected == 0)
259260
currentPosition = fileNameInfo.lpstrFile;
@@ -262,7 +263,7 @@ void ReplaceWemData(HWND window)
262263
currentFileName = fileNameInfo.lpstrFile;
263264
} else {
264265
currentPosition += strlen(currentPosition) + 1;
265-
currentFileName = alloca(UNICODE_STRING_MAX_BYTES+1); // assuming long paths and utf-8 are enabled, this might be correct? idc
266+
currentFileName = currentFileNameBuffer;
266267
sprintf(currentFileName, "%s\\%s", fileNameInfo.lpstrFile, currentPosition);
267268
}
268269
printf("current file name: \"%s\"\n", currentFileName);

0 commit comments

Comments
 (0)