diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2011-12-10 14:29:38 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2011-12-10 14:29:38 +0100 |
commit | 4dd52ffe39f0394f52a6f799f32478718b5eaf9b (patch) | |
tree | 3fa75f12b755743f7a3d9cee42ec60c5a1b090cd /recording.c | |
parent | 773c4419ea8819279d4dfab2f46f179350bdaa51 (diff) | |
download | vdr-4dd52ffe39f0394f52a6f799f32478718b5eaf9b.tar.gz vdr-4dd52ffe39f0394f52a6f799f32478718b5eaf9b.tar.bz2 |
Fixed a memory leak in cRecordings::ScanVideoDir() in case there are too many link levels
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/recording.c b/recording.c index 2a8108bc..698b2db0 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 2.40 2011/12/10 14:12:55 kls Exp $ + * $Id: recording.c 2.41 2011/12/10 14:22:37 kls Exp $ */ #include "recording.h" @@ -1103,25 +1103,21 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev struct dirent *e; while ((Foreground || Running()) && (e = d.Next()) != NULL) { if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) { - char *buffer = strdup(AddDirectory(DirName, e->d_name)); + cString buffer = AddDirectory(DirName, e->d_name); struct stat st; if (lstat(buffer, &st) == 0) { int Link = 0; if (S_ISLNK(st.st_mode)) { if (LinkLevel > MAX_LINK_LEVEL) { - isyslog("max link level exceeded - not scanning %s", buffer); + isyslog("max link level exceeded - not scanning %s", *buffer); continue; } Link = 1; - char *old = buffer; - buffer = ReadLink(old); - free(old); - if (!buffer) + buffer = ReadLink(buffer); + if (!*buffer) continue; - if (stat(buffer, &st) != 0) { - free(buffer); + if (stat(buffer, &st) != 0) continue; - } } if (S_ISDIR(st.st_mode)) { if (endswith(buffer, deleted ? DELEXT : RECEXT)) { @@ -1144,7 +1140,6 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev ScanVideoDir(buffer, Foreground, LinkLevel + Link); } } - free(buffer); } } } |