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.coopersm...@oracle.com> --- src/XEVI.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/XEVI.c b/src/XEVI.c index 6d77fdf..c9b172c 100644 --- a/src/XEVI.c +++ b/src/XEVI.c @@ -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) -- 1.7.9.2 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel