summaryrefslogtreecommitdiff
path: root/plugins/wavpack
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-29 10:15:43 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-29 10:15:43 +0200
commitde64b6b001f08d352610d38df135b5dfc9d94c2e (patch)
tree829ed457fcdbd9aa6b23271ccfde16fca2e1bc5c /plugins/wavpack
parentdf6821b79111405295d4da1ab4bb7c4ed5bcfb55 (diff)
use stack memory for wavpack correction file name
Diffstat (limited to 'plugins/wavpack')
-rw-r--r--plugins/wavpack/wavpack.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c
index d0e743f4..861dec75 100644
--- a/plugins/wavpack/wavpack.c
+++ b/plugins/wavpack/wavpack.c
@@ -106,11 +106,15 @@ wv_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
return -1;
}
- char *c_fname = malloc (strlen (it->fname) + 10);
- strcpy (c_fname, it->fname);
- strcat (c_fname, "c");
- info->c_file = deadbeef->fopen (c_fname);
- free (c_fname);
+ char *c_fname = alloca (strlen (it->fname) + 2);
+ if (c_fname) {
+ strcpy (c_fname, it->fname);
+ strcat (c_fname, "c");
+ info->c_file = deadbeef->fopen (c_fname);
+ }
+ else {
+ fprintf (stderr, "wavpack warning: failed to alloc memory for correction file name\n");
+ }
char error[80];
info->ctx = WavpackOpenFileInputEx (&wsr, info->file, info->c_file, error, OPEN_2CH_MAX, 0);