summaryrefslogtreecommitdiff
path: root/plugins/wma
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2013-01-15 21:50:03 +0100
committerGravatar waker <wakeroid@gmail.com>2013-01-15 21:50:03 +0100
commitd4adb3583c71720ac102300c267dd7e20303128f (patch)
tree9c999774a42060332f141dcb023baddf56ebddf1 /plugins/wma
parente1b1779e917ae2ee1f194a831380c44e64c96255 (diff)
wma: fix crashes, fix freezes
Diffstat (limited to 'plugins/wma')
-rw-r--r--plugins/wma/wma_plugin.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/plugins/wma/wma_plugin.c b/plugins/wma/wma_plugin.c
index f16d77cb..197c5a54 100644
--- a/plugins/wma/wma_plugin.c
+++ b/plugins/wma/wma_plugin.c
@@ -57,7 +57,7 @@ typedef struct {
int startsample;
int endsample;
int skipsamples;
- char *buffer;
+ char buffer[100000]; // can't predict its size, so set to max
int remaining;
} wmaplug_info_t;
@@ -112,14 +112,6 @@ wmaplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
return -1;
}
- int n_subframes = info->wfx.packet_size / info->wfx.blockalign;
- int bufsize = info->wmadec.frame_len * (info->wfx.bitspersample / 8) * info->wfx.channels * n_subframes;
- info->buffer = malloc (bufsize);
- if (!info->buffer) {
- trace ("wma error: failed to malloc a buffer for %d samples\n", info->wmadec.frame_len);
- return -1;
- }
-
info->startsample = it->startsample;
info->endsample = it->endsample;
_info->plugin = &plugin;
@@ -148,10 +140,6 @@ wmaplug_free (DB_fileinfo_t *_info) {
#if USE_FFMPEG
ff_wma_end (&info->wmadec);
#endif
- if (info->buffer) {
- free (info->buffer);
- info->buffer = NULL;
- }
if (info->fp) {
deadbeef->fclose (info->fp);
info->fp = NULL;
@@ -226,6 +214,11 @@ wmaplug_read (DB_fileinfo_t *_info, char *bytes, int size) {
}
}
+ if (info->remaining == 0) {
+ // error
+ break;
+ }
+
if (info->skipsamples > 0) {
int skip = info->skipsamples * samplesize;
skip = min (info->remaining, skip);