Fix a file descriptor leak when using an invitation.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 2 Sep 2017 19:52:44 +0000 (21:52 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 2 Sep 2017 19:52:44 +0000 (21:52 +0200)
Found by cppcheck.

src/invitation.c

index b10151f..0dfd9ea 100644 (file)
@@ -611,6 +611,8 @@ make_names:
        FILE *finv = fopen(filename, "w");
        if(!finv || fwrite(data, datalen, 1, finv) != 1) {
                fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno));
+               fclose(fh);
+               fclose(f);
                fclose(finv);
                return false;
        }