aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-09-03 22:45:33 +0200
committerMax Kellermann <max@duempel.org>2012-09-03 22:45:33 +0200
commit013e8479afce485bec1c93b8b58fb558abaac6ed (patch)
treef6e9d88e0ff5df5304be9d9f285dfe20290d78fc /src
parent27535a7f781d7fbc87b2c6f9ec217cf7daca3323 (diff)
downloadmpd-013e8479afce485bec1c93b8b58fb558abaac6ed.tar.gz
mpd-013e8479afce485bec1c93b8b58fb558abaac6ed.tar.xz
mpd-013e8479afce485bec1c93b8b58fb558abaac6ed.zip
AudioCompress: abort on out-of-memory
This library crashes on out-of-memory (NULL pointer dereference). There's not much useful MPD can do in such a situation, so let's explicitly abort instead, just like GLib does.
Diffstat (limited to 'src')
-rw-r--r--src/AudioCompress/compress.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/AudioCompress/compress.c b/src/AudioCompress/compress.c
index 36cdfd8dd..fd51ac3a3 100644
--- a/src/AudioCompress/compress.c
+++ b/src/AudioCompress/compress.c
@@ -33,6 +33,9 @@ struct Compressor {
struct Compressor *Compressor_new(unsigned int history)
{
struct Compressor *obj = malloc(sizeof(struct Compressor));
+ if (obj == NULL)
+ /* out of memory, not much we can do */
+ abort();
obj->prefs.target = TARGET;
obj->prefs.maxgain = GAINMAX;
@@ -61,6 +64,10 @@ void Compressor_delete(struct Compressor *obj)
static int *resizeArray(int *data, int newsz, int oldsz)
{
data = realloc(data, newsz*sizeof(int));
+ if (data == NULL)
+ /* out of memory, not much we can do */
+ abort();
+
if (newsz > oldsz)
memset(data + oldsz, 0, sizeof(int)*(newsz - oldsz));
return data;