From 072a7fa407d109a8c87365bbf2e9c164fbb116fc Mon Sep 17 00:00:00 2001 From: Jochen Dolze Date: Mon, 22 Mar 2010 00:57:51 +0100 Subject: Another CheckIndex fix ;) --- markad-standalone.cpp | 3 ++- marks.cpp | 47 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/markad-standalone.cpp b/markad-standalone.cpp index 0530131..22ce24d 100644 --- a/markad-standalone.cpp +++ b/markad-standalone.cpp @@ -365,6 +365,7 @@ void cMarkAdStandalone::Process(const char *Directory) if (lastiframe) { MarkAdMark tempmark; + tempmark.Type=MT_COMMON; tempmark.Position=lastiframe; char *buf; @@ -389,7 +390,7 @@ void cMarkAdStandalone::Process(const char *Directory) if (marks.Save(Directory,macontext.Video.Info.FramesPerSecond,isTS)) { - bool bIndexError; + bool bIndexError=false; if (marks.CheckIndex(Directory,isTS,&bIndexError)) { if (bIndexError) diff --git a/marks.cpp b/marks.cpp index a4ae4b6..5a59b2e 100644 --- a/marks.cpp +++ b/marks.cpp @@ -213,11 +213,10 @@ char *clMarks::IndexToHMSF(int Index, double FramesPerSecond) bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError) { if (!IndexError) return false; - if (!first) - { - *IndexError=false; - return true; - } + *IndexError=false; + + if (!first) return true; + char *ipath=NULL; if (asprintf(&ipath,"%s/index%s",Directory,isTS ? "" : ".vdr")==-1) return false; @@ -229,20 +228,44 @@ bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError) while (mark) { if (isTS) - { + { off_t offset = mark->position * sizeof(struct tIndexTS); - if (lseek(fd,offset,SEEK_SET)!=offset) return true; + if (lseek(fd,offset,SEEK_SET)!=offset) + { + *IndexError=true; + break; + } struct tIndexTS IndexTS; - if (read(fd,&IndexTS,sizeof(IndexTS))!=sizeof(IndexTS)) return true; - if (IndexTS.independent) return false; + if (read(fd,&IndexTS,sizeof(IndexTS))!=sizeof(IndexTS)) + { + *IndexError=true; + break; + } + if (!IndexTS.independent) + { + *IndexError=true; + break; + } } else { off_t offset = mark->position * sizeof(struct tIndexVDR); - if (lseek(fd,offset,SEEK_SET)!=offset) return true; + if (lseek(fd,offset,SEEK_SET)!=offset) + { + *IndexError=true; + break; + } struct tIndexVDR IndexVDR; - if (read(fd,&IndexVDR,sizeof(IndexVDR))!=sizeof(IndexVDR)) return true; - if (IndexVDR.type==1) return false; + if (read(fd,&IndexVDR,sizeof(IndexVDR))!=sizeof(IndexVDR)) + { + *IndexError=true; + break; + } + if (IndexVDR.type!=1) + { + *IndexError=true; + break; + } } mark=mark->Next(); } -- cgit v1.2.3