Fixed reallocating memory in cTsToPes::PutTs()

This commit is contained in:
Klaus Schmidinger 2011-02-20 17:37:24 +01:00
parent e85852672f
commit 82a13c7a0e
3 changed files with 9 additions and 4 deletions

View File

@ -677,6 +677,7 @@ Oliver Endriss <o.endriss@gmx.de>
for reporting broken index generation in TS recordings after a buffer overflow for reporting broken index generation in TS recordings after a buffer overflow
for fixing the way the OSD size is determined on full featured DVB cards for fixing the way the OSD size is determined on full featured DVB cards
for his input on calculating the Aspect factor in GetOsdSize() for his input on calculating the Aspect factor in GetOsdSize()
for suggesting a better way of handling calls to realloc()
Reinhard Walter Buchner <rw.buchner@freenet.de> Reinhard Walter Buchner <rw.buchner@freenet.de>
for adding some satellites to 'sources.conf' for adding some satellites to 'sources.conf'

View File

@ -6537,3 +6537,4 @@ Video Disk Recorder Revision History
- Added Serbian language texts (thanks to Milan Cvijanovic). - Added Serbian language texts (thanks to Milan Cvijanovic).
- Fixed reallocating memory in the "pictures" plugin (reported by Paul Menzel, with - Fixed reallocating memory in the "pictures" plugin (reported by Paul Menzel, with
input from Oliver Endriss). input from Oliver Endriss).
- Fixed reallocating memory in cTsToPes::PutTs() (suggested by Oliver Endriss).

11
remux.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: remux.c 2.48 2010/11/01 12:29:17 kls Exp $ * $Id: remux.c 2.49 2011/02/20 17:27:47 kls Exp $
*/ */
#include "remux.h" #include "remux.h"
@ -666,9 +666,12 @@ void cTsToPes::PutTs(const uchar *Data, int Length)
return; // skip everything before the first payload start return; // skip everything before the first payload start
Length = TsGetPayload(&Data); Length = TsGetPayload(&Data);
if (length + Length > size) { if (length + Length > size) {
size = max(KILOBYTE(2), length + Length); int NewSize = max(KILOBYTE(2), length + Length);
data = (uchar *)realloc(data, size); if (uchar *NewData = (uchar *)realloc(data, NewSize)) {
if (!data) { data = NewData;
size = NewSize;
}
else {
Reset(); Reset();
return; return;
} }