Update of /cvsroot/monetdb/pathfinder/runtime
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20005

Modified Files:
      Tag: Nov2009
        xrpc_client.mx 
Log Message:
Always free resp on error.
Found by Coverity.


Index: xrpc_client.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_client.mx,v
retrieving revision 1.56.2.3
retrieving revision 1.56.2.4
diff -u -d -r1.56.2.3 -r1.56.2.4
--- xrpc_client.mx      7 Dec 2009 12:23:16 -0000       1.56.2.3
+++ xrpc_client.mx      23 Dec 2009 09:44:26 -0000      1.56.2.4
@@ -734,15 +734,12 @@
     resp = buffer_create(MAX_BUF_SIZE);
     if (!resp || resp->len == 0) {
         GDKerror("response2bat: failed to create buffer for XRPC response 
message\n");
-        if (resp)
-            buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
 
     if( !(ret = stream_readline(in, respStatus, 1024)) ){
         GDKerror("response2bat: failed to receive response from %s:%d", host, 
port);
-        buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
 
     /* We only speak HTTP/1.1 */
@@ -758,8 +755,7 @@
             GDKerror("%s\n", respStatus);
             ret = stream_readline(in, respStatus, 1024);
         } while (ret > 0);
-        buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
     respStatus[ret -2] = '\0';
 
@@ -770,8 +766,7 @@
     } while (ret > 0);
     if (ret < 0) {
         GDKerror("response2bat: failed to receive response from %s:%d", host, 
port);
-        buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
 
     /* Now, we can check the response status */
@@ -785,27 +780,24 @@
         } while (ret > 0);
         if (ret < 0) {
             GDKerror("response2bat: failed to receive response from %s:%d", 
host, port);
-            return NULL;
+            goto error;
         }
         resp->buf[resp->pos] = 0;
         handle_error_msg(resp->buf);
-        buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
 
     /* Start timing Client DeSerialisation */
     lng time_xrpcClntDeSeria = GDKusec();
     if (!(shredBAT = BATnew(TYPE_str, TYPE_bat, 32))){
         GDKerror("response2bat: failed to malloc shredBAT\n");
-        buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
 
     if(shred(shredBAT, NULL, NULL, in, 0, NULL, NULL, NULL) ==GDK_FAIL) {
         GDKerror("response2bat: invalid XRPC response received\n");
         BBPreclaim(shredBAT);
-        buffer_destroy(resp);
-        return NULL;
+        goto error;
     }
     /* Stop timing Client DeSerialisation */
     time_xrpcClntDeSeria = GDKusec() - time_xrpcClntDeSeria;
@@ -816,6 +808,10 @@
     }
 
     return shredBAT;
+  error:
+    if (resp)
+        buffer_destroy(resp);
+    return NULL;
 }
 
 static buffer *


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to