diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2020-10-31 21:01:02 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2020-10-31 21:01:02 -0700 |
commit | 2d30328f9c5390eb38d4052028cd00bafaa151d4 (patch) | |
tree | 51d54c55f0510112e5944d126270439ba9101a5c /write.c | |
parent | 899eadee6750ea39ddb6b874529c29c011599bb2 (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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; } |