Skip to contentSkip to conversation

ui/vnc: Fix use of free() instead of g_free()

PATCH Applied Stefan Weil 2 participants 2 messages Oct 7, 2011 – Nov 1, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/vnc: Fix use of free() instead of g_free()

Please note that mechlist still uses malloc / strdup / free.

---
 ui/vnc-auth-sasl.c   |    8 ++++----
 ui/vnc-enc-hextile.c |    4 ++--
 ui/vnc-tls.c         |    2 +-
 ui/vnc.c             |    8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)
ui/vnc-auth-sasl.c +4 -4
index e96095a..23b1bf5 100644
@@ -34,7 +34,7 @@ void vnc_sasl_client_cleanup(VncState *vs)
         vs->sasl.runSSF = vs->sasl.waitWriteSSF = vs->sasl.wantSSF = 0;
         vs->sasl.encodedLength = vs->sasl.encodedOffset = 0;
         vs->sasl.encoded = NULL;
-        free(vs->sasl.username);
+        g_free(vs->sasl.username);
         free(vs->sasl.mechlist);
         vs->sasl.username = vs->sasl.mechlist = NULL;
         sasl_dispose(&vs->sasl.conn);
@@ -506,7 +506,7 @@ void start_auth_sasl(VncState *vs)
         goto authabort;
 
     if (!(remoteAddr = vnc_socket_remote_addr("%s;%s", vs->csock))) {
-        free(localAddr);
+        g_free(localAddr);
         goto authabort;
     }
 
@@ -518,8 +518,8 @@ void start_auth_sasl(VncState *vs)
                           NULL, /* Callbacks, not needed */
                           SASL_SUCCESS_DATA,
                           &vs->sasl.conn);
-    free(localAddr);
-    free(remoteAddr);
+    g_free(localAddr);
+    g_free(remoteAddr);
     localAddr = remoteAddr = NULL;
 
     if (err != SASL_OK) {
ui/vnc-enc-hextile.c +2 -2
index d2905c8..c860dbb 100644
@@ -80,8 +80,8 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
                                   last_bg, last_fg, &has_bg, &has_fg);
         }
     }
-    free(last_fg);
-    free(last_bg);
+    g_free(last_fg);
+    g_free(last_bg);
 
     return 1;
 }
ui/vnc-tls.c +1 -1
index ffbd172..3aaa939 100644
@@ -413,7 +413,7 @@ void vnc_tls_client_cleanup(struct VncState *vs)
         vs->tls.session = NULL;
     }
     vs->tls.wiremode = VNC_WIREMODE_CLEAR;
-    free(vs->tls.dname);
+    g_free(vs->tls.dname);
 }
 
 
ui/vnc.c +4 -4
index fc3a612..3107918 100644
@@ -2880,7 +2880,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
     if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) {
         fprintf(stderr, "Failed to initialize SASL auth %s",
                 sasl_errstring(saslErr, NULL, NULL));
-        free(vs->display);
+        g_free(vs->display);
         vs->display = NULL;
         return -1;
     }
@@ -2894,7 +2894,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
         else
             vs->lsock = inet_connect(display, SOCK_STREAM);
         if (-1 == vs->lsock) {
-            free(vs->display);
+            g_free(vs->display);
             vs->display = NULL;
             return -1;
         } else {
@@ -2915,10 +2915,10 @@ int vnc_display_open(DisplayState *ds, const char *display)
             vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900);
         }
         if (-1 == vs->lsock) {
-            free(dpy);
+            g_free(dpy);
             return -1;
         } else {
-            free(vs->display);
+            g_free(vs->display);
             vs->display = dpy;
         }
     }
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 3 lines · Stefan Weil

Please note that mechlist still uses malloc / strdup / free.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 103 lines
---
  ui/vnc-auth-sasl.c   |    8 ++++----
  ui/vnc-enc-hextile.c |    4 ++--
  ui/vnc-tls.c         |    2 +-
  ui/vnc.c             |    8 ++++----
  4 files changed, 11 insertions(+), 11 deletions(-)
ui/vnc-auth-sasl.c +4 -4
index e96095a..23b1bf5 100644
@@ -34,7 +34,7 @@ void vnc_sasl_client_cleanup(VncState *vs)
          vs->sasl.runSSF = vs->sasl.waitWriteSSF = vs->sasl.wantSSF = 0;
          vs->sasl.encodedLength = vs->sasl.encodedOffset = 0;
          vs->sasl.encoded = NULL;
-        free(vs->sasl.username);
+        g_free(vs->sasl.username);
          free(vs->sasl.mechlist);
          vs->sasl.username = vs->sasl.mechlist = NULL;
          sasl_dispose(&vs->sasl.conn);
@@ -506,7 +506,7 @@ void start_auth_sasl(VncState *vs)
          goto authabort;
 
      if (!(remoteAddr = vnc_socket_remote_addr("%s;%s", vs->csock))) {
-        free(localAddr);
+        g_free(localAddr);
          goto authabort;
      }
 
@@ -518,8 +518,8 @@ void start_auth_sasl(VncState *vs)
                            NULL, /* Callbacks, not needed */
                            SASL_SUCCESS_DATA,
                            &vs->sasl.conn);
-    free(localAddr);
-    free(remoteAddr);
+    g_free(localAddr);
+    g_free(remoteAddr);
      localAddr = remoteAddr = NULL;
 
      if (err != SASL_OK) {
ui/vnc-enc-hextile.c +2 -2
index d2905c8..c860dbb 100644
@@ -80,8 +80,8 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
                                    last_bg, last_fg,&has_bg,&has_fg);
          }
      }
-    free(last_fg);
-    free(last_bg);
+    g_free(last_fg);
+    g_free(last_bg);
 
      return 1;
  }
ui/vnc-tls.c +1 -1
index ffbd172..3aaa939 100644
@@ -413,7 +413,7 @@ void vnc_tls_client_cleanup(struct VncState *vs)
          vs->tls.session = NULL;
      }
      vs->tls.wiremode = VNC_WIREMODE_CLEAR;
-    free(vs->tls.dname);
+    g_free(vs->tls.dname);
  }
 
 
ui/vnc.c +4 -4
index fc3a612..3107918 100644
@@ -2880,7 +2880,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
      if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) {
          fprintf(stderr, "Failed to initialize SASL auth %s",
                  sasl_errstring(saslErr, NULL, NULL));
-        free(vs->display);
+        g_free(vs->display);
          vs->display = NULL;
          return -1;
      }
@@ -2894,7 +2894,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
          else
              vs->lsock = inet_connect(display, SOCK_STREAM);
          if (-1 == vs->lsock) {
-            free(vs->display);
+            g_free(vs->display);
              vs->display = NULL;
              return -1;
          } else {
@@ -2915,10 +2915,10 @@ int vnc_display_open(DisplayState *ds, const char *display)
              vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900);
          }
          if (-1 == vs->lsock) {
-            free(dpy);
+            g_free(dpy);
              return -1;
          } else {
-            free(vs->display);
+            g_free(vs->display);
              vs->display = dpy;
          }
      }