ead: fix resource leak in tinysrp
authorAndrea Dalla Costa <andrea@dallacosta.me>
Sat, 28 Dec 2019 20:05:16 +0000 (21:05 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 5 Jan 2020 18:36:46 +0000 (19:36 +0100)
Add call to fclose for file pointer fp in function t_openpw.
The resource leak could happen during an error handling.

Signed-off-by: Andrea Dalla Costa <andrea@dallacosta.me>
package/network/services/ead/src/tinysrp/t_pw.c

index 18e929bb79e7a66e5093fb44196166d6345e8cbb..5da5e26b781ff9be347a6c6df82730ec6560fcce 100644 (file)
@@ -94,8 +94,10 @@ t_openpw(fp)
   else
     close_flag = 0;
 
-  if((tpw = malloc(sizeof(struct t_pw))) == NULL)
+  if((tpw = malloc(sizeof(struct t_pw))) == NULL) {
+    fclose(fp);
     return NULL;
+  }
   tpw->instream = fp;
   tpw->close_on_exit = close_flag;
   tpw->state = FILE_ONLY;