From d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 25 Feb 2011 15:25:42 +0100 Subject: Now checking the result of all realloc() calls --- dvbsubtitle.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'dvbsubtitle.c') diff --git a/dvbsubtitle.c b/dvbsubtitle.c index 39dddb59..98a45188 100644 --- a/dvbsubtitle.c +++ b/dvbsubtitle.c @@ -7,7 +7,7 @@ * Original author: Marco Schlüßler * With some input from the "subtitle plugin" by Pekka Virtanen * - * $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; } } -- cgit v1.2.3