src/utils_ovs.c: Initialize pdb->sock to -1 earlier.
authorFlorian Forster <octo@collectd.org>
Mon, 20 Nov 2017 10:13:02 +0000 (11:13 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 20 Nov 2017 10:13:07 +0000 (11:13 +0100)
ovs_db_destroy() was called before the field was initialized, leading to
close(0) being called.

src/utils_ovs.c

index e3f5caa..3c448e3 100644 (file)
@@ -1006,6 +1006,7 @@ ovs_db_t *ovs_db_init(const char *node, const char *service,
   ovs_db_t *pdb = calloc(1, sizeof(*pdb));
   if (pdb == NULL)
     return NULL;
   ovs_db_t *pdb = calloc(1, sizeof(*pdb));
   if (pdb == NULL)
     return NULL;
+  pdb->sock = -1;
 
   /* store the OVS DB address */
   sstrncpy(pdb->node, node, sizeof(pdb->node));
 
   /* store the OVS DB address */
   sstrncpy(pdb->node, node, sizeof(pdb->node));
@@ -1047,7 +1048,6 @@ ovs_db_t *ovs_db_init(const char *node, const char *service,
   }
 
   /* init polling thread */
   }
 
   /* init polling thread */
-  pdb->sock = -1;
   if (ovs_db_poll_thread_init(pdb) < 0) {
     ovs_db_destroy(pdb);
     return NULL;
   if (ovs_db_poll_thread_init(pdb) < 0) {
     ovs_db_destroy(pdb);
     return NULL;