chiark / gitweb /
Merge memory hygeine branch
[disorder] / lib / client.c
index d9023a985bd3074d1da1d571ca5f0969a19a821f..2cbcfa76201324f07dc0668975b5dd5c51a98291 100644 (file)
@@ -519,7 +519,7 @@ int disorder_close(disorder_client *c) {
   c->ident = 0;
   xfree(c->user);
   c->user = 0;
-  return 0;
+  return ret;
 }
 
 /** @brief Play a track
@@ -653,6 +653,7 @@ static int disorder_somequeue(disorder_client *c,
     if(!strcmp(l, ".")) {
       *qt = 0;
       *qp = qh;
+      xfree(l);
       return 0;
     }
     q = xmalloc(sizeof *q);
@@ -660,6 +661,7 @@ static int disorder_somequeue(disorder_client *c,
       *qt = q;
       qt = &q->next;
     }
+    xfree(l);
   }
   if(ferror(c->fpin)) {
     byte_xasprintf((char **)&c->last, "input error: %s", strerror(errno));
@@ -712,9 +714,11 @@ static int readlist(disorder_client *c, char ***vecp, int *nvecp) {
       if(nvecp)
        *nvecp = v.nvec;
       *vecp = v.vec;
+      xfree(l);
       return 0;
     }
-    vector_append(&v, l + (*l == '.'));
+    vector_append(&v, xstrdup(l + (*l == '.')));
+    xfree(l);
   }
   if(ferror(c->fpin)) {
     byte_xasprintf((char **)&c->last, "input error: %s", strerror(errno));
@@ -865,7 +869,9 @@ int disorder_prefs(disorder_client *c, const char *track, struct kvp **kp) {
     k->name = pvec[0];
     k->value = pvec[1];
     kp = &k->next;
+    xfree(pvec);
   }
+  free_strings(nvec, vec);
   *kp = 0;
   return 0;
 }