summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
-rw-r--r--HISTORY2
-rw-r--r--tools.c10
-rw-r--r--tools.h4
4 files changed, 10 insertions, 7 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 2eb32fec..899225c9 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -190,6 +190,7 @@ Stefan Huelswitt <huels@iname.com>
for fixing handling of pmAudioOnlyBlack
for pointing out possible race conditions in handling childTid in cThread
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>
for pointing out that there are channels that have a symbol rate higher than
diff --git a/HISTORY b/HISTORY
index 8595bb75..57d13c7b 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3355,3 +3355,5 @@ Video Disk Recorder Revision History
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
that has DD and selecting the DD audio track).
+- Fixed a memory leak in AddDirectory() and strescape() (thanks to Stefan Huelswitt
+ for reporting these).
diff --git a/tools.c b/tools.c
index 2f130c78..0501d76d 100644
--- a/tools.c
+++ b/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 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"
@@ -199,7 +199,7 @@ cString strescape(const char *s, const char *chars)
}
if (t)
*t = 0;
- return s;
+ return cString(s, t != NULL);
}
bool startswith(const char *s, const char *p)
@@ -250,7 +250,7 @@ cString AddDirectory(const char *DirName, const char *FileName)
{
char *buf;
asprintf(&buf, "%s/%s", DirName && *DirName ? DirName : ".", FileName);
- return buf;
+ return cString(buf, true);
}
cString itoa(int n)
@@ -513,9 +513,9 @@ uint64 cTimeMs::Elapsed(void)
// --- 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()
diff --git a/tools.h b/tools.h
index 9067eb8d..bf190890 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -61,7 +61,7 @@ class cString {
private:
char *s;
public:
- cString(const char *S = NULL);
+ cString(const char *S = NULL, bool TakePointer = false);
virtual ~cString();
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.)