]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_client.c: fix Coverity CID#32409 Missing unlock
authorMarek Schimara <Marek.Schimara@bull.net>
Wed, 15 Jun 2016 13:31:27 +0000 (15:31 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Thu, 23 Jun 2016 14:32:33 +0000 (16:32 +0200)
        CWE-667 / https://cwe.mitre.org/data/definitions/667.html

src/rrd_client.c

index d1fd435e130a5794f2af4ac960e277e2e99cf761..b9a4585eb6ed75275d3c911a842b8002950177dd 100644 (file)
@@ -1421,12 +1421,16 @@ int rrdc_fetch (const char *filename, /* {{{ */
   status = buffer_add_string (file_path, &buffer_ptr, &buffer_free);
   free (file_path);
 
-  if (status != 0)
+  if (status != 0) {
+    mutex_unlock(&lock);
     return (ENOBUFS);
+  }
 
   status = buffer_add_string (cf, &buffer_ptr, &buffer_free);
-  if (status != 0)
+  if (status != 0) {
+    mutex_unlock(&lock);
     return (ENOBUFS);
+  }
 
   if ((ret_start != NULL) && (*ret_start > 0))
   {
@@ -1434,8 +1438,10 @@ int rrdc_fetch (const char *filename, /* {{{ */
     snprintf (tmp, sizeof (tmp), "%lu", (unsigned long) *ret_start);
     tmp[sizeof (tmp) - 1] = 0;
     status = buffer_add_string (tmp, &buffer_ptr, &buffer_free);
-    if (status != 0)
+    if (status != 0) {
+      mutex_unlock(&lock);
       return (ENOBUFS);
+    }
 
     if ((ret_end != NULL) && (*ret_end > 0))
     {