summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-27 18:27:21 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-27 18:27:21 +0200
commitbc9bb6d0395cd9fc343407e1275e804d938abced (patch)
tree9e2b860d79b1d3f9f79c1e32328855ce4ba63003 /plugins
parentf5bdcf539e33e4dfe9aabf2849042f782bc5cdb0 (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);