aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Effect
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-01-06 16:10:03 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-01-06 16:10:03 +0000
commit1b0fef3d25ed94518f4f6b1914a7d7e71aae80c5 (patch)
treec2edf437731b5753f50d19c49ce28609c3d09ed5 /src/plugins/Effect
parente7a02ec7fee6fee4eaa04a31f53120c62caccbda (diff)
downloadqmmp-1b0fef3d25ed94518f4f6b1914a7d7e71aae80c5.tar.gz
qmmp-1b0fef3d25ed94518f4f6b1914a7d7e71aae80c5.tar.bz2
qmmp-1b0fef3d25ed94518f4f6b1914a7d7e71aae80c5.zip
added realloc result checking
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8589 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Effect')
-rw-r--r--src/plugins/Effect/crossfade/crossfadeplugin.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/plugins/Effect/crossfade/crossfadeplugin.cpp b/src/plugins/Effect/crossfade/crossfadeplugin.cpp
index 29e76bd86..424bd5037 100644
--- a/src/plugins/Effect/crossfade/crossfadeplugin.cpp
+++ b/src/plugins/Effect/crossfade/crossfadeplugin.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2015 by Ilya Kotov <forkotov02@ya.ru> *
+ * Copyright (C) 2009-2019 by Ilya Kotov <forkotov02@ya.ru> *
* Copyright (C) 2009 by Sebastian Pipping <sebastian@pipping.org> *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -65,11 +65,23 @@ void CrossfadePlugin::applyEffect(Buffer *b)
if(m_buffer_at + b->samples > m_buffer_size)
{
m_buffer_size = m_buffer_at + b->samples;
+ float *tmp = m_buffer;
m_buffer = (float *)realloc(m_buffer, m_buffer_size * sizeof(float));
+ if(!m_buffer)
+ {
+ qWarning("CrossfadePlugin: unable to allocate %zu bytes", m_buffer_size);
+ m_buffer_size = 0;
+ if(tmp)
+ free(tmp);
+ }
+ }
+
+ if(m_buffer)
+ {
+ memcpy(m_buffer + m_buffer_at, b->data, b->samples * sizeof(float));
+ m_buffer_at += b->samples;
+ b->samples = 0;
}
- memcpy(m_buffer + m_buffer_at, b->data, b->samples * sizeof(float));
- m_buffer_at += b->samples;
- b->samples = 0;
}
else if(m_buffer_at > 0)
m_state = PROCESSING;