diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2022-01-24 10:44:21 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2022-01-24 10:44:21 +0100 |
commit | ea1ad945b4fdedda8923b88d68d412743845a17e (patch) | |
tree | 1d1b45be2916b66e895828b66f8b5f1c7a5a4ad0 /recording.c | |
parent | 8cde8464ebfe816783fdbf0504c0c9aa4b899da1 (diff) | |
download | vdr-ea1ad945b4fdedda8923b88d68d412743845a17e.tar.gz vdr-ea1ad945b4fdedda8923b88d68d412743845a17e.tar.bz2 |
Fixed handling error conditions in the index file
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/recording.c b/recording.c index 47587de7..0bff62b6 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 5.13 2021/07/01 15:40:46 kls Exp $ + * $Id: recording.c 5.14 2022/01/24 10:44:21 kls Exp $ */ #include "recording.h" @@ -2604,6 +2604,8 @@ cIndexFile::cIndexFile(const char *FileName, bool Record, bool IsPesRecording, b if (safe_read(f, index, size_t(buf.st_size)) != buf.st_size) { esyslog("ERROR: can't read from file '%s'", *fileName); free(index); + size = 0; + last = -1; index = NULL; } else if (isPesRecording) @@ -2617,8 +2619,11 @@ cIndexFile::cIndexFile(const char *FileName, bool Record, bool IsPesRecording, b else LOG_ERROR_STR(*fileName); } - else + else { esyslog("ERROR: can't allocate %zd bytes for index '%s'", size * sizeof(tIndexTs), *fileName); + size = 0; + last = -1; + } } } else @@ -2817,7 +2822,7 @@ int cIndexFile::GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber, off int cIndexFile::GetClosestIFrame(int Index) { - if (last > 0) { + if (index && last > 0) { Index = constrain(Index, 0, last); if (index[Index].independent) return Index; |