summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2009-09-27 22:40:45 +0200
committerJochen Dolze <vdr@dolze.de>2009-09-27 22:40:45 +0200
commitc51d2148c69cdda76f5b72e25a52c73c2b319f95 (patch)
treed259b20c39547b4a6f676685952ce47314a7f8aa
parent577280a1796e5cf90d5eb05d2232690ab83f0bd8 (diff)
downloadvdr-plugin-markad-c51d2148c69cdda76f5b72e25a52c73c2b319f95.tar.gz
vdr-plugin-markad-c51d2148c69cdda76f5b72e25a52c73c2b319f95.tar.bz2
Fixed handling of asprintf result
-rw-r--r--audio.cpp5
-rw-r--r--common.cpp10
-rw-r--r--markad-standalone.cpp28
-rw-r--r--recv.cpp6
-rw-r--r--video.cpp11
5 files changed, 31 insertions, 29 deletions
diff --git a/audio.cpp b/audio.cpp
index d34ceae..923812d 100644
--- a/audio.cpp
+++ b/audio.cpp
@@ -71,9 +71,8 @@ MarkAdMark *cMarkAdAudio::Process(int LastIFrame)
if (ChannelChange(macontext->Audio.Info.Channels,channels))
{
char *buf=NULL;
- asprintf(&buf,"audio channel change from %i to %i (%i)", channels,
- macontext->Audio.Info.Channels,LastIFrame);
- if (buf)
+ if (asprintf(&buf,"audio channel change from %i to %i (%i)", channels,
+ macontext->Audio.Info.Channels,LastIFrame)!=-1)
{
isyslog("markad [%i]: %s",recvnumber, buf);
AddMark(LastIFrame,buf);
diff --git a/common.cpp b/common.cpp
index 8869265..d8549e5 100644
--- a/common.cpp
+++ b/common.cpp
@@ -60,9 +60,8 @@ void cMarkAdCommon::SetTimerMarks(int LastIFrame)
if ((time(NULL)>macontext->General.StartTime) && (!macontext->State.ContentStarted))
{
char *buf=NULL;
- asprintf(&buf,"start of %s content (%i)",
- macontext->General.ManualRecording ? "user" : "event",LastIFrame);
- if (buf)
+ if (asprintf(&buf,"start of %s content (%i)",
+ macontext->General.ManualRecording ? "user" : "event",LastIFrame)!=-1)
{
isyslog("markad [%i]: %s",recvnumber,buf);
AddMark(LastIFrame,buf);
@@ -75,9 +74,8 @@ void cMarkAdCommon::SetTimerMarks(int LastIFrame)
(macontext->State.ContentStarted) && (!macontext->State.ContentStopped))
{
char *buf=NULL;
- asprintf(&buf,"stop of %s content (%i)",
- macontext->General.ManualRecording ? "user" : "event",LastIFrame);
- if (buf)
+ if (asprintf(&buf,"stop of %s content (%i)",
+ macontext->General.ManualRecording ? "user" : "event",LastIFrame)!=-1)
{
isyslog("markad [%i]: %s",recvnumber,buf);
AddMark(LastIFrame,buf);
diff --git a/markad-standalone.cpp b/markad-standalone.cpp
index 18ab1a0..03b123d 100644
--- a/markad-standalone.cpp
+++ b/markad-standalone.cpp
@@ -72,16 +72,14 @@ bool cMarkAdIndex::Open(const char *Directory)
{
if (!Directory) return false;
char *ibuf;
- asprintf(&ibuf,"%s/index.vdr",Directory);
- if (!ibuf) return false;
+ if (asprintf(&ibuf,"%s/index.vdr",Directory)==-1) return false;
index_fd = open(ibuf,O_RDONLY);
free(ibuf);
maxfiles=999;
if (index_fd==-1)
{
// second try just index -> ts format
- asprintf(&ibuf,"%s/index",Directory);
- if (!ibuf) return false;
+ if (asprintf(&ibuf,"%s/index",Directory)==-1) return false;
index_fd = open(ibuf,O_RDONLY);
free(ibuf);
if (index_fd==-1)
@@ -106,6 +104,7 @@ cMarkAdIndex::cMarkAdIndex(const char *Directory)
iframe=0;
offset=0;
index=0;
+ index_fd=-1;
ts=false;
Open(Directory);
}
@@ -135,16 +134,23 @@ bool cMarkAdStandalone::ProcessFile(int Number)
datalen=70688; // multiple of 188
data=(uchar *) malloc(datalen);
if (!data) return false;
- asprintf(&fbuf,"%s/%05i.ts",dir,Number);
+ if (asprintf(&fbuf,"%s/%05i.ts",dir,Number)==-1)
+ {
+ free(data);
+ return false;
+ }
}
else
{
datalen=69632; // VDR paket size
data=(uchar *) malloc(datalen);
- if (!data)return false;
- asprintf(&fbuf,"%s/%03i.vdr",dir,Number);
+ if (!data) return false;
+ if (asprintf(&fbuf,"%s/%03i.vdr",dir,Number)==-1)
+ {
+ free(data);
+ return false;
+ }
}
- if (!fbuf) return false;
int f=open(fbuf,O_RDONLY);
free(fbuf);
@@ -583,7 +589,11 @@ int main(int argc, char *argv[])
if ( bFork )
{
isyslog("markad (forked) pid: %d", getpid());
- chdir("/");
+ if (chdir("/")==-1)
+ {
+ perror("chdir");
+ exit(EXIT_FAILURE);
+ }
if (setsid() == (pid_t)(-1))
{
perror("setsid");
diff --git a/recv.cpp b/recv.cpp
index f9562bf..f0cd2c5 100644
--- a/recv.cpp
+++ b/recv.cpp
@@ -128,8 +128,7 @@ cMarkAdReceiver::~cMarkAdReceiver()
tempmark.Position=lastiframe;
char *buf;
- asprintf(&buf,"stop of user content (%i)",lastiframe);
- if (buf)
+ if (asprintf(&buf,"stop of user content (%i)",lastiframe)!=-1)
{
tempmark.Comment=buf;
AddMark(&tempmark,0);
@@ -239,8 +238,7 @@ void cMarkAdReceiver::AddMark(MarkAdMark *mark, int Priority)
if (newmark)
{
char *buf;
- asprintf(&buf,"P%i %s",Priority,mark->Comment);
- if (buf)
+ if (asprintf(&buf,"P%i %s",Priority,mark->Comment)!=-1)
{
if (newmark->comment) free(newmark->comment);
newmark->comment=buf;
diff --git a/video.cpp b/video.cpp
index cb64d38..ad52153 100644
--- a/video.cpp
+++ b/video.cpp
@@ -223,8 +223,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
if ((hret>0) && (borderiframe))
{
char *buf=NULL;
- asprintf(&buf,"detected start of horiz. borders (%i)",borderiframe);
- if (buf)
+ if (asprintf(&buf,"detected start of horiz. borders (%i)",borderiframe)!=-1)
{
isyslog("markad [%i]: %s",recvnumber,buf);
AddMark(borderiframe,buf);
@@ -235,8 +234,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
if ((hret<0) && (borderiframe))
{
char *buf=NULL;
- asprintf(&buf,"detected stop of horiz. borders (%i)",borderiframe);
- if (buf)
+ if (asprintf(&buf,"detected stop of horiz. borders (%i)",borderiframe)!=-1)
{
isyslog("markad [%i]: %s",recvnumber,buf);
AddMark(borderiframe,buf);
@@ -248,11 +246,10 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
if (AspectRatioChange(&macontext->Video.Info.AspectRatio,&aspectratio))
{
char *buf=NULL;
- asprintf(&buf,"aspect ratio change from %i:%i to %i:%i (%i)",
+ if (asprintf(&buf,"aspect ratio change from %i:%i to %i:%i (%i)",
aspectratio.Num,aspectratio.Den,
macontext->Video.Info.AspectRatio.Num,
- macontext->Video.Info.AspectRatio.Den,LastIFrame);
- if (buf)
+ macontext->Video.Info.AspectRatio.Den,LastIFrame)!=-1)
{
isyslog("markad [%i]: %s",recvnumber, buf);
AddMark(LastIFrame,buf);