diff options
author | David Tardon <dtardon@redhat.com> | 2011-05-18 09:37:54 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2011-05-18 14:57:14 +0200 |
commit | 059dfe015f2b44eaf8126c1a747e6d4407dda131 (patch) | |
tree | 7c77e12564ce4756723fce9cacfa4dcd513ea6af /vcl | |
parent | 033460d47225f09bbff2ec01533ccfd2f0556c9b (diff) |
avoid memory leak
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/fontsubset/ttcr.cxx | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index 7a785b9bf99f..4356636e90a2 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -399,16 +399,19 @@ int StreamToFile(TrueTypeCreator *_this, const char* fname) FILE* fd; if ((r = StreamToMemory(_this, &ptr, &length)) != SF_OK) return r; - if (!fname) return SF_BADFILE; - if ((fd = fopen(fname, "wb")) == NULL) return SF_BADFILE; - - if (fwrite(ptr, 1, length, fd) != length) { - r = SF_FILEIO; - } else { - r = SF_OK; + if (fname && (fd = fopen(fname, "wb")) != NULL) + { + if (fwrite(ptr, 1, length, fd) != length) { + r = SF_FILEIO; + } else { + r = SF_OK; + } + fclose(fd); + } + else + { + r = SF_BADFILE; } - - fclose(fd); free(ptr); return r; } |