Now checking the result of all realloc() calls

This commit is contained in:
Klaus Schmidinger
2011-02-25 15:25:42 +01:00
parent e145ee45e2
commit d1ab9dbc5f
12 changed files with 188 additions and 77 deletions

View File

@@ -7,7 +7,7 @@
* Original author: Marco Schl<68><6C>ler <marco@lordzodiac.de>
* With some input from the "subtitle plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
*
* $Id: dvbsubtitle.c 2.8 2010/10/24 12:25:45 kls Exp $
* $Id: dvbsubtitle.c 2.9 2011/02/25 15:13:32 kls Exp $
*/
#include "dvbsubtitle.h"
@@ -570,12 +570,17 @@ void cDvbSubtitleAssembler::Reset(void)
bool cDvbSubtitleAssembler::Realloc(int Size)
{
if (Size > size) {
size = max(Size, 2048);
data = (uchar *)realloc(data, size);
if (!data) {
Size = max(Size, 2048);
if (uchar *NewBuffer = (uchar *)realloc(data, Size)) {
size = Size;
data = NewBuffer;
}
else {
esyslog("ERROR: can't allocate memory for subtitle assembler");
length = 0;
size = 0;
free(data);
data = NULL;
return false;
}
}