diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-06-24 06:48:54 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-06-24 06:48:54 +0000 |
commit | 64e685e51690547beeea580db1e07e7e122958da (patch) | |
tree | 30c697916febfa6139553f7a8c609e8422db7c72 /libsylph | |
parent | 99c745455b059217fb78f111620b27b0f1b7870b (diff) |
my_tmpfile(): win32: fixed a memory leak.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2911 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/utils.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c index 18c9917c..ac00e03e 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -3767,6 +3767,8 @@ FILE *my_tmpfile(void) close(fd); } + g_free(fname); + return fp; #else const gchar suffix[] = ".XXXXXX"; @@ -3784,8 +3786,7 @@ FILE *my_tmpfile(void) if (!progname) progname = "sylph"; proglen = strlen(progname); - Xalloca(fname, tmplen + 1 + proglen + sizeof(suffix), - return tmpfile()); + fname = g_malloc(tmplen + 1 + proglen + sizeof(suffix)); memcpy(fname, tmpdir, tmplen); fname[tmplen] = G_DIR_SEPARATOR; @@ -3793,14 +3794,20 @@ FILE *my_tmpfile(void) memcpy(fname + tmplen + 1 + proglen, suffix, sizeof(suffix)); fd = g_mkstemp(fname); - if (fd < 0) + if (fd < 0) { + g_free(fname); return tmpfile(); + } g_unlink(fname); fp = fdopen(fd, "w+b"); - if (!fp) + if (!fp) { + perror("fdopen"); close(fd); + } + + g_free(fname); return fp; #endif |