diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-03-08 20:09:46 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-03-08 20:16:19 -0800 |
commit | dde40e03c10808b964dc1d6a7eb48156dd5ce4a2 (patch) | |
tree | 6462bb0d97fec9b94da78f5d4233f04967d36f4c | |
parent | d5447c0156f556114dbf97d6064c0c7b0fcd5f70 (diff) |
XeviGetVisualInfo: Free & clear *evi_return, not evi_return pointer
evi_return is passed in as a pointer to a location into which
XeviGetVisualInfo is expected to write a pointer to the memory
it allocated for the returned structures. If we're failing and
bailing out, we need to dispose of the pointer we set, not the
one passed into us (which the caller may have put on the stack
or allocated as part of a larger structure).
Flagged by cppcheck 1.64:
[lib/libXext/src/XEVI.c:182] -> [lib/libXext/src/XEVI.c:186]:
(warning) Possible null pointer dereference: evi_return - otherwise it
is redundant to check it against null.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/XEVI.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -183,8 +183,10 @@ Status XeviGetVisualInfo( _XEatDataWords(dpy, rep.length); UnlockDisplay(dpy); SyncHandle(); - if (evi_return) - Xfree(evi_return); + if (*evi_return) { + Xfree(*evi_return); + *evi_return = NULL; + } if (temp_xInfo) Xfree(temp_xInfo); if (temp_conflict) |