From 1b0fef3d25ed94518f4f6b1914a7d7e71aae80c5 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 6 Jan 2019 16:10:03 +0000 Subject: added realloc result checking git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8589 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Output/shout/shoutoutput.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/plugins/Output') diff --git a/src/plugins/Output/shout/shoutoutput.cpp b/src/plugins/Output/shout/shoutoutput.cpp index 9ca6e9a95..90a4b0b49 100644 --- a/src/plugins/Output/shout/shoutoutput.cpp +++ b/src/plugins/Output/shout/shoutoutput.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Ilya Kotov * + * Copyright (C) 2017-2019 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -98,7 +98,16 @@ qint64 ShoutOutput::writeAudio(unsigned char *data, qint64 maxSize) if(required_frames > m_soxr_buf_frames) { m_soxr_buf_frames = required_frames; + float *tmp = m_soxr_buf; m_soxr_buf = (float *)realloc(m_soxr_buf, m_soxr_buf_frames * sizeof(float) * chan); + if(!m_soxr_buf) + { + qWarning("ShoutOutput: unable to allocate %zu bytes", m_soxr_buf_frames * sizeof(float) * chan); + m_soxr_buf_frames = 0; + if(tmp) + free(tmp); + return -1; + } } size_t done = 0; -- cgit v1.2.3-13-gbd6f