1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Fixed a memory leak in AddDirectory() and strescape()

This commit is contained in:
Klaus Schmidinger 2005-02-05 10:12:14 +01:00
parent 9484b537bc
commit 32e0b131c9
4 changed files with 10 additions and 7 deletions

View File

@ -190,6 +190,7 @@ Stefan Huelswitt <huels@iname.com>
for fixing handling of pmAudioOnlyBlack for fixing handling of pmAudioOnlyBlack
for pointing out possible race conditions in handling childTid in cThread for pointing out possible race conditions in handling childTid in cThread
for fixing a possible race condition in cDevice::Action() and cTSBuffer::Action() for fixing a possible race condition in cDevice::Action() and cTSBuffer::Action()
for reporting a memory leak in AddDirectory() and strescape()
Ulrich Röder <roeder@efr-net.de> Ulrich Röder <roeder@efr-net.de>
for pointing out that there are channels that have a symbol rate higher than for pointing out that there are channels that have a symbol rate higher than

View File

@ -3355,3 +3355,5 @@ Video Disk Recorder Revision History
recording (thanks to Sascha Volkenandt for reporting a problem when starting recording (thanks to Sascha Volkenandt for reporting a problem when starting
replay of a recording that has no Dolby Digital audio after switching to a channel replay of a recording that has no Dolby Digital audio after switching to a channel
that has DD and selecting the DD audio track). that has DD and selecting the DD audio track).
- Fixed a memory leak in AddDirectory() and strescape() (thanks to Stefan Huelswitt
for reporting these).

10
tools.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: tools.c 1.88 2005/01/16 11:47:44 kls Exp $ * $Id: tools.c 1.89 2005/02/05 10:10:30 kls Exp $
*/ */
#include "tools.h" #include "tools.h"
@ -199,7 +199,7 @@ cString strescape(const char *s, const char *chars)
} }
if (t) if (t)
*t = 0; *t = 0;
return s; return cString(s, t != NULL);
} }
bool startswith(const char *s, const char *p) bool startswith(const char *s, const char *p)
@ -250,7 +250,7 @@ cString AddDirectory(const char *DirName, const char *FileName)
{ {
char *buf; char *buf;
asprintf(&buf, "%s/%s", DirName && *DirName ? DirName : ".", FileName); asprintf(&buf, "%s/%s", DirName && *DirName ? DirName : ".", FileName);
return buf; return cString(buf, true);
} }
cString itoa(int n) cString itoa(int n)
@ -513,9 +513,9 @@ uint64 cTimeMs::Elapsed(void)
// --- cString --------------------------------------------------------------- // --- cString ---------------------------------------------------------------
cString::cString(const char *S) cString::cString(const char *S, bool TakePointer)
{ {
s = S ? strdup(S) : NULL; s = TakePointer ? (char *)S : S ? strdup(S) : NULL;
} }
cString::~cString() cString::~cString()

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: tools.h 1.65 2005/01/16 11:39:58 kls Exp $ * $Id: tools.h 1.66 2005/02/05 10:00:22 kls Exp $
*/ */
#ifndef __TOOLS_H #ifndef __TOOLS_H
@ -61,7 +61,7 @@ class cString {
private: private:
char *s; char *s;
public: public:
cString(const char *S = NULL); cString(const char *S = NULL, bool TakePointer = false);
virtual ~cString(); virtual ~cString();
operator const char * () const { return s; } // for use in (const char *) context operator const char * () const { return s; } // for use in (const char *) context
const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.) const char * operator*() const { return s; } // for use in (const void *) context (printf() etc.)