xmpp: close fd in case of write error
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 07:29:47 +0000 (09:29 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 07:31:49 +0000 (09:31 +0200)
src/modules/xmpp/xode_from.c

index f2d9b54..8a78f4b 100644 (file)
@@ -225,8 +225,10 @@ int xode_to_file(char *file, xode node)
 
     doc = xode_to_str(node);
     i = write(fd,doc,strlen(doc));
-    if(i < 0)
+    if(i < 0) {
+        close(fd);
         return -1;
+    }
 
     close(fd);
     return 1;