summaryrefslogtreecommitdiff
path: root/write.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2020-10-31 21:01:02 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2020-10-31 21:01:02 -0700
commit2d30328f9c5390eb38d4052028cd00bafaa151d4 (patch)
tree51d54c55f0510112e5944d126270439ba9101a5c /write.c
parent899eadee6750ea39ddb6b874529c29c011599bb2 (diff)
writeFile: avoid file leak on errors
Resolves issues found by Oracle Parfait 4.0 static analyser: File Leak [file-ptr-leak]: Leaked File out at line 337 of app/fonttosfnt/write.c in function 'writeFile'. out initialized at line 330 with fopen File Leak [file-ptr-leak]: Leaked File out at line 366 of app/fonttosfnt/write.c in function 'writeFile'. out initialized at line 330 with fopen Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'write.c')
-rw-r--r--write.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/write.c b/write.c
index ca7c95a..e68b70c 100644
--- a/write.c
+++ b/write.c
@@ -334,7 +334,7 @@ writeFile(char *filename, FontPtr font)
current_cmap = makeCmap(font);
if(current_cmap == NULL) {
fprintf(stderr, "Couldn't build cmap.\n");
- return -1;
+ goto fail;
}
fontMetrics(font);
@@ -363,7 +363,7 @@ writeFile(char *filename, FontPtr font)
strike->indexSubTables = makeIndexSubTables(strike, current_cmap);
if(!strike->indexSubTables) {
fprintf(stderr, "Couldn't build indexSubTable.\n");
- return -1;
+ goto fail;
}
strike = strike->next;
}
@@ -449,6 +449,7 @@ writeFile(char *filename, FontPtr font)
return 0;
fail:
+ fclose(out);
unlink(filename);
return -1;
}