From e77c0cd47c14cf0f76e79139141833277cda510a Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 9 Oct 2013 11:46:36 +0000 Subject: Small addition to fix for STR #2985 - see comment in source file. Fixes a small potential of another leak. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9998 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_x.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index ced8f27c4..660a0a929 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -821,16 +821,19 @@ void fl_sendClientMessage(Window window, Atom message, } -/* - Get window property value (32 bit format) +/* + Get window property value (32 bit format) Returns zero on success, -1 on error 'data' should be freed with XFree() using this pattern: - + unsigned long *data = 0; if (0 == get_xwinprop(....., &nitems, &data) ) { ..success.. } else { ..fail.. } if ( data ) { XFree(data); data=0; } + + Note: 'data' can be non-zero, even if the return value is -1 (error) and + should hence be XFree'd *after* the if/else statement, as described above. */ static int get_xwinprop(Window wnd, Atom prop, long max_length, unsigned long *nitems, unsigned long **data) { @@ -1907,9 +1910,9 @@ int Fl_X::ewmh_supported() { if (0 == get_xwinprop(child, fl_NET_SUPPORTING_WM_CHECK, 64, &nitems, &words) ) { if ( nitems == 1) result = (child == words[0]); - if ( words ) { XFree(words); words = 0; } } } + if ( words ) { XFree(words); words = 0; } } return result; -- cgit v1.2.3