summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-27 18:27:21 +0200
committerGravatar Martin Bagge / brother (or Pootle...) <brother@bsnet.se>2010-05-28 15:01:20 +0200
commit3ffdce3a408a5ca067aadb783b4fbeea8a224283 (patch)
tree7246ac3cb621edff56968204cd8879fa5cc13104 /plugins
parent0ae8cf2511921612f29941371a63a9b4004893c1 (diff)
fixed potential memleak in artwork.c copy_file
Diffstat (limited to 'plugins')
-rw-r--r--plugins/artwork/artwork.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c
index 4af9658b..88052e6e 100644
--- a/plugins/artwork/artwork.c
+++ b/plugins/artwork/artwork.c
@@ -159,11 +159,6 @@ check_dir (const char *dir, mode_t mode)
static int
copy_file (const char *in, const char *out) {
trace ("copying %s to %s\n", in, out);
- char *buf = malloc (BUFFER_SIZE);
- if (!buf) {
- trace ("artwork: failed to alloc %d bytes\n", BUFFER_SIZE);
- return -1;
- }
FILE *fin = fopen (in, "rb");
if (!fin) {
trace ("artwork: failed to open file %s for reading\n", in);
@@ -175,6 +170,13 @@ copy_file (const char *in, const char *out) {
trace ("artwork: failed to open file %s for writing\n", out);
return -1;
}
+ char *buf = malloc (BUFFER_SIZE);
+ if (!buf) {
+ trace ("artwork: failed to alloc %d bytes\n", BUFFER_SIZE);
+ fclose (fin);
+ fclose (fout);
+ return -1;
+ }
fseek (fin, 0, SEEK_END);
size_t sz = ftell (fin);