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

Fixed a memory leak in cRecordings::ScanVideoDir() in case there are too many link levels

This commit is contained in:
Klaus Schmidinger 2011-12-10 14:29:38 +01:00
parent 773c4419ea
commit 4dd52ffe39
3 changed files with 10 additions and 11 deletions

View File

@ -2545,6 +2545,8 @@ Sundararaj Reel <sundararaj.reel@googlemail.com>
for reporting some missing 'const' in tChannelID for reporting some missing 'const' in tChannelID
for suggesting to add optional case insensitive sorting to cStringList::Sort() for suggesting to add optional case insensitive sorting to cStringList::Sort()
for reporting a bug in handling symbolic links in cRecordings::ScanVideoDir() for reporting a bug in handling symbolic links in cRecordings::ScanVideoDir()
for reporting a memory leak in cRecordings::ScanVideoDir() in case there are too
many link levels
Ales Jurik <ajurik@quick.cz> Ales Jurik <ajurik@quick.cz>
for reporting broken SI data on Czech/Slovak channels after changing the default for reporting broken SI data on Czech/Slovak channels after changing the default

View File

@ -6787,3 +6787,5 @@ Video Disk Recorder Revision History
- Fixed bonding more than two devices. - Fixed bonding more than two devices.
- Fixed handling symbolic links in cRecordings::ScanVideoDir() (reported by - Fixed handling symbolic links in cRecordings::ScanVideoDir() (reported by
Sundararaj Reel). Sundararaj Reel).
- Fixed a memory leak in cRecordings::ScanVideoDir() in case there are too many
link levels (reported by Sundararaj Reel).

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: 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" #include "recording.h"
@ -1103,25 +1103,21 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev
struct dirent *e; struct dirent *e;
while ((Foreground || Running()) && (e = d.Next()) != NULL) { while ((Foreground || Running()) && (e = d.Next()) != NULL) {
if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) { 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; struct stat st;
if (lstat(buffer, &st) == 0) { if (lstat(buffer, &st) == 0) {
int Link = 0; int Link = 0;
if (S_ISLNK(st.st_mode)) { if (S_ISLNK(st.st_mode)) {
if (LinkLevel > MAX_LINK_LEVEL) { if (LinkLevel > MAX_LINK_LEVEL) {
isyslog("max link level exceeded - not scanning %s", buffer); isyslog("max link level exceeded - not scanning %s", *buffer);
continue; continue;
} }
Link = 1; Link = 1;
char *old = buffer; buffer = ReadLink(buffer);
buffer = ReadLink(old); if (!*buffer)
free(old);
if (!buffer)
continue; continue;
if (stat(buffer, &st) != 0) { if (stat(buffer, &st) != 0)
free(buffer);
continue; continue;
}
} }
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
if (endswith(buffer, deleted ? DELEXT : RECEXT)) { 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); ScanVideoDir(buffer, Foreground, LinkLevel + Link);
} }
} }
free(buffer);
} }
} }
} }