xlib: fix memory leak on Display close
authorJohn Sheu <sheu@google.com>
Tue, 12 Apr 2016 18:53:00 +0000 (12:53 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 12 Apr 2016 19:56:41 +0000 (13:56 -0600)
The XMesaVisual instances freed in the visuals table on display close
are being freed with a free() call, instead of XMesaDestroyVisual(),
causing a memory leak.

Signed-off-by: John Sheu <sheu@google.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/x11/fakeglx.c
src/mesa/drivers/x11/xm_api.c

index 80b71765e6cd83ff75c2765653084281f47e1f9c..2f4d966973e8ef9220a93fda186fa61bb98cba8b 100644 (file)
@@ -794,7 +794,7 @@ destroy_visuals_on_display(Display *dpy)
       if (VisualTable[i]->display == dpy) {
          /* remove this visual */
          int j;
-         free(VisualTable[i]);
+         XMesaDestroyVisual(VisualTable[i]);
          for (j = i; j < NumVisuals - 1; j++)
             VisualTable[j] = VisualTable[j + 1];
          NumVisuals--;
index 65e7ca89d325fe103e09e7c817c44170cfd5d362..82c4d188d5a8d891b542bd21780037ee3615193c 100644 (file)
@@ -856,6 +856,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
                                 accum_red_size, accum_green_size,
                                 accum_blue_size, accum_alpha_size,
                                 0)) {
+      free(v->visinfo);
       free(v);
       return NULL;
    }