info: write_data: properly clean up an output buffer
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 2 Dec 2015 12:02:06 +0000 (13:02 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 2 Dec 2015 19:54:17 +0000 (20:54 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/info/olsrd_info.c

index eea370a..b1bf2ae 100644 (file)
@@ -190,8 +190,11 @@ static void write_data(void *foo __attribute__ ((unused))) {
       if (result <= 0 || outbuffer.written[i] == outbuffer.size[i]) {
         /* close this socket and cleanup*/
         close(outbuffer.socket[i]);
+        outbuffer.socket[i] = -1;
         free(outbuffer.buffer[i]);
         outbuffer.buffer[i] = NULL;
+        outbuffer.size[i] = 0;
+        outbuffer.written[i] = 0;
 
         for (j = i + 1; j < outbuffer.count; j++) {
           outbuffer.buffer[j - 1] = outbuffer.buffer[j];