ead: fix resource leak in tinysrp
[openwrt/staging/jogo.git] / 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;