mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed memory handling in cString::Append()
This commit is contained in:
parent
8a282ef267
commit
5cfa736ad0
@ -3510,6 +3510,7 @@ Stefan Herdler <herdler@gmx.de>
|
||||
too early
|
||||
for reporting a bug in using the default sort mode in a video directory without a
|
||||
".sort" file
|
||||
for reporting faulty memory handling in cString::Append()
|
||||
|
||||
Tobias Faust <tobias.faust@gmx.de>
|
||||
for the original "jumpingseconds" patch
|
||||
|
1
HISTORY
1
HISTORY
@ -9462,3 +9462,4 @@ Video Disk Recorder Revision History
|
||||
indicate this change.
|
||||
- Added a device hook for detecting whether a device provides EIT data (thanks to
|
||||
Winfried Köhler).
|
||||
- Fixed memory handling in cString::Append() (reported by Stefan Herdler).
|
||||
|
16
tools.c
16
tools.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.c 4.11 2018/03/04 10:28:04 kls Exp $
|
||||
* $Id: tools.c 4.12 2020/06/10 20:52:10 kls Exp $
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
@ -1099,12 +1099,16 @@ cString &cString::operator=(const char *String)
|
||||
|
||||
cString &cString::Append(const char *String)
|
||||
{
|
||||
int l1 = strlen(s);
|
||||
if (String) {
|
||||
int l1 = s ? strlen(s) : 0;
|
||||
int l2 = strlen(String);
|
||||
char *p = (char *)realloc(s, l1 + l2 + 1);
|
||||
if (p != s)
|
||||
strcpy(p, s);
|
||||
strcpy(p + l1, String);
|
||||
if (char *p = (char *)realloc(s, l1 + l2 + 1)) {
|
||||
s = p;
|
||||
strcpy(s + l1, String);
|
||||
}
|
||||
else
|
||||
esyslog("ERROR: out of memory");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user