Menu

#10 Crash on filesize zero

open
ThumbView (11)
5
2008-02-06
2008-02-06
Anonymous
No

in ThumbExtractor.cpp, there's a bit of code in the tool tip code:

/* this part is credited to DrunkenCoder, only he can make stuff like this when he's sober */
const char *sz[] = { "Gb", "Mb", "Kb", "bytes"}, **p = sz;
unsigned m = 1 << 30;
for(; filesize < m; m >>= 10)
++p;
infoTip << L"\nSize: " << std::setprecision(2) << std::fixed << static_cast<float>(filesize)/m << L" " << *p;

in the case where filesize == 0, this will go past the sz array and crash windows explorer. several easy ways of fixing this, you can just wrap the for loop in an if-else, if the filesize is zero, assign it directly to sz[3], otherwise run the for loop. doubt anyone will care, but if anyone else finds this project useful like I did, you might need to make this change.

Discussion


Log in to post a comment.