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
|
too early
|
||||||
for reporting a bug in using the default sort mode in a video directory without a
|
for reporting a bug in using the default sort mode in a video directory without a
|
||||||
".sort" file
|
".sort" file
|
||||||
|
for reporting faulty memory handling in cString::Append()
|
||||||
|
|
||||||
Tobias Faust <tobias.faust@gmx.de>
|
Tobias Faust <tobias.faust@gmx.de>
|
||||||
for the original "jumpingseconds" patch
|
for the original "jumpingseconds" patch
|
||||||
|
1
HISTORY
1
HISTORY
@ -9462,3 +9462,4 @@ Video Disk Recorder Revision History
|
|||||||
indicate this change.
|
indicate this change.
|
||||||
- Added a device hook for detecting whether a device provides EIT data (thanks to
|
- Added a device hook for detecting whether a device provides EIT data (thanks to
|
||||||
Winfried Köhler).
|
Winfried Köhler).
|
||||||
|
- Fixed memory handling in cString::Append() (reported by Stefan Herdler).
|
||||||
|
18
tools.c
18
tools.c
@ -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: 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"
|
#include "tools.h"
|
||||||
@ -1099,12 +1099,16 @@ cString &cString::operator=(const char *String)
|
|||||||
|
|
||||||
cString &cString::Append(const char *String)
|
cString &cString::Append(const char *String)
|
||||||
{
|
{
|
||||||
int l1 = strlen(s);
|
if (String) {
|
||||||
int l2 = strlen(String);
|
int l1 = s ? strlen(s) : 0;
|
||||||
char *p = (char *)realloc(s, l1 + l2 + 1);
|
int l2 = strlen(String);
|
||||||
if (p != s)
|
if (char *p = (char *)realloc(s, l1 + l2 + 1)) {
|
||||||
strcpy(p, s);
|
s = p;
|
||||||
strcpy(p + l1, String);
|
strcpy(s + l1, String);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
esyslog("ERROR: out of memory");
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user