summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2011-05-18 09:37:54 +0200
committerDavid Tardon <dtardon@redhat.com>2011-05-18 14:57:14 +0200
commit90225a18000e2620cd69162fc0a226d7de8bdeee (patch)
tree7a02a4eeaedb7018998abb4bff0adb8f46504721
parent15c15980bd7b13d00e31d9fc08dcf14165d3304d (diff)
avoid memory leak
-rw-r--r--vcl/source/fontsubset/ttcr.cxx21
1 files changed, 12 insertions, 9 deletions
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index 8235c3a27e..8834465d50 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;
}