On 6-11-2013 1:27, mathog wrote:
On 05-Nov-2013 12:31, Johan Engelen wrote:
Hi all, Clang found a potential bug. In /src/extension/internal/wmf-inout.cpp, line 1408: int32_t width, height, colortype, numCt, invert; if( (iUsage != U_DIB_RGB_COLORS) || !(dibparams = wget_DIB_params( // this returns pointers and values, but allocates no memory dib, &px, &ct, &numCt, &width, &height, &colortype, &invert )) ){
Now if the first condition is true ("(iUsage != U_DIB_RGB_COLORS)") the second part will not be executed,
That is intentional. What is the full message? Does it go away if this change is made to line 1395?
int dibparams;
to
int dibparams = U_BI_RGB;
The full warning I don't have anymore. It's about uninitialized variables. There are many variables that are not initialized immediately in that function which is very bad by itself and should be fixed. In particular, not initializing dibparams is a bug because of the if-statement later on: if(dibparams == U_BI_JPEG .... Regardless if it's a real bug or not, please immediately initialize every variable always, unless it is extremely obvious that it's going to be initialized correctly in the next 2 lines.
Please also add a comment that the ordering in the if-statement is intentional, because that is not obvious at all from the code. (please also think about avoiding relying on the short-circuit evaluation)
Thanks for the fixes, Johan