diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-27 16:34:09 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-27 16:34:09 +0200 |
commit | f7534e2524d4b14a457540a987e168bc28f61e5d (patch) | |
tree | 21d4b9a8a80208208fcc30a1b70f7af3879d91f5 | |
parent | 4e7c62530a7342e7a71047feca398d6612eeca3a (diff) | |
download | EpisodeBrowser-f7534e2524d4b14a457540a987e168bc28f61e5d.tar.gz |
Fix memory bug.
swprintf_s excepts the NUMBER of characters, not the SIZE of the
buffer. The argument is named sizeOfBuffer in the documentation, but
don't let that fool you (like it did me).
Interestingly enough, this bug causes a crash ONLY when compiling
WITHOUT optimizations (at least on my system). The crash was
introduced in 3a133c4, where I removed the `static' attribute from
tszRating.
I guess the optimizer moves the memory around such that the memory
after the string happens to be unimportant.
-rw-r--r-- | c/episodelistview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index 3b16a06..ea14b5b 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -443,7 +443,7 @@ r: int iRating; } wchar_t wszRating[3]; - swprintf_s(wszRating, sizeof(wszRating), L"%d", iRating); + swprintf_s(wszRating, sizeof(wszRating)/sizeof(*wszRating), L"%d", iRating); ListView_SetItemText(hWnd, pLvi->iItem, ELVSIRATING, wszRating); } |