msvcrt: move error condition before memory allocation (found by Smatch) [1/3, resend]

Alexandre Julliard julliard at
Fri Sep 28 03:55:52 CDT 2007

Lionel_Debroux <lionel_debroux at> writes:

> _wfullpath leaks some heap memory in an error paths. Found in Michael
> Stefaniuc's list of Wine potential bugs detected by Smatch.
> Fixed by moving the error treatment before the allocation, since the
> error treatment doesn't fire up if there was a memory allocation (due to
> size = MAX_PATH; assignment).
> Is there anything wrong with this patch ?

Yes, you are using the size before checking if the buffer is NULL (in
which case the size is meaningless), and as you said yourself the
error treatment isn't used if there was an allocation, so there's no
leak to fix here.

Alexandre Julliard
julliard at

More information about the wine-devel mailing list