Browse Source

Free strings returned by XGetAtomName to avoid leakage.

Markus Schöngart 12 years ago
parent
commit
e5e6b22e01
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Samples/shell/src/x11/ShellX11.cpp

+ 5 - 1
Samples/shell/src/x11/ShellX11.cpp

@@ -198,6 +198,7 @@ void Shell::EventLoop(ShellIdleFunction idle_function)
 		while (XPending(display) > 0)
 		{
 			XEvent event;
+			char *event_type = 0;
 			XNextEvent(display, &event);
 
 			switch (event.type)
@@ -206,8 +207,11 @@ void Shell::EventLoop(ShellIdleFunction idle_function)
 				{
 					// The only message we register for is WM_DELETE_WINDOW, so if we receive a client message then the
 					// window has been closed.
-					if (strcmp(XGetAtomName(display, event.xclient.message_type), "WM_PROTOCOLS") == 0)
+					event_type = XGetAtomName(display, event.xclient.message_type);
+					if (strcmp(event_type, "WM_PROTOCOLS") == 0)
 						running = false;
+					XFree(event_type);
+					event_type = 0;
 				}
 				break;