Quellcode durchsuchen

x11: Fix various very minor memory leaks

rdb vor 6 Tagen
Ursprung
Commit
626e419972

+ 5 - 0
panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

@@ -402,6 +402,7 @@ choose_pixel_format(const FrameBufferProperties &properties,
             << ", context_has_pixmap = " << _context_has_pixmap << "\n";
         }
 
+        XFree(configs);
         return;
       }
     }
@@ -414,6 +415,10 @@ choose_pixel_format(const FrameBufferProperties &properties,
     _visuals = nullptr;
   }
 
+  if (configs != nullptr) {
+    XFree(configs);
+  }
+
   glxdisplay_cat.warning()
     << "No suitable FBConfig contexts available; using XVisual only.\n"
     << _fbprops << "\n";

+ 6 - 2
panda/src/x11display/x11GraphicsWindow.cxx

@@ -634,10 +634,10 @@ process_events() {
     Atom type;
     int format;
     unsigned long nItem, bytesAfter;
-    unsigned char *new_window_properties = NULL;
+    unsigned char *new_window_properties = nullptr;
     // gather all properties from the active dispplay and window
     XGetWindowProperty(_display, _xwindow, wmState, 0, LONG_MAX, false, AnyPropertyType, &type, &format, &nItem, &bytesAfter, &new_window_properties);
-    if (nItem > 0) {
+    if (nItem > 0 && new_window_properties != nullptr) {
       x11GraphicsPipe *x11_pipe;
       DCAST_INTO_V(x11_pipe, _pipe);
       // run through all found items
@@ -650,6 +650,7 @@ process_events() {
           is_maximized = true;
         }
       }
+      XFree(new_window_properties);
     }
 
     // Debug entry
@@ -1532,6 +1533,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) {
   XSetWMProperties(_display, _xwindow, window_name_p, window_name_p,
                    nullptr, 0, size_hints_p, wm_hints_p, class_hints_p);
 
+  if (window_name_p != nullptr) {
+    XFree(window_name.value);
+  }
   if (size_hints_p != nullptr) {
     XFree(size_hints_p);
   }