From efcb6216fad91fb8a71aa7aff4c8b3b055e2cb69 Mon Sep 17 00:00:00 2001 From: Joachim Wilke Date: Sat, 1 Jan 2011 16:58:38 +0100 Subject: Fix compiler warnings - Added several asprintfs result checks - Fixed a sprintf call --- lcd.c | 7 +++++-- lcdproc.c | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lcd.c b/lcd.c index 4229166..6c8151e 100644 --- a/lcd.c +++ b/lcd.c @@ -67,7 +67,10 @@ cLcd::~cLcd() { } bool cLcd::Connect( const char *host, unsigned int port ) { - asprintf(&(this->host), "%s", host); + if (asprintf(&(this->host), "%s", host) < 0) { + syslog(LOG_ERR, "lcdproc: error allocating memory in asprintf"); + return false; + } this->port = port; cLcd::Open(); @@ -912,7 +915,7 @@ void cLcd::Action(void) { // LCD output thread if ( (now.tv_usec < WakeUpCycle) && (replayDvbApi) ) { char tempbuffer[16]; replayDvbApi->GetIndex(Current, Total, false); Total=(Total==0)?1:Total; - sprintf(tempbuffer,IndexToHMSF(Total)); + sprintf(tempbuffer,"%s",(const char*)IndexToHMSF(Total)); SetProgress(IndexToHMSF(Current),tempbuffer, (100 * Current) / Total); } diff --git a/lcdproc.c b/lcdproc.c index 4ce0385..ff55b99 100644 --- a/lcdproc.c +++ b/lcdproc.c @@ -121,7 +121,10 @@ void cLcdFeed::SetAudioTrack(int Index, const char * const *Tracks) OsdTitle(trVDR("Button$Audio")); if (AudioTrack) free(AudioTrack); - asprintf(&AudioTrack, "%s", Tracks[Index]); + if (asprintf(&AudioTrack, "%s", Tracks[Index]) < 0) { + syslog(LOG_ERR, "lcdproc: error allocating memory in asprintf"); + return; + } OsdCurrentItem(AudioTrack); } @@ -129,13 +132,22 @@ void cLcdFeed::SetAudioChannel(int AudioChannel){ char * TrackDescription; switch (AudioChannel){ case 0: - asprintf(&TrackDescription, "%s (%s)", AudioTrack, tr("Stereo")); + if (asprintf(&TrackDescription, "%s (%s)", AudioTrack, tr("Stereo")) < 0) { + syslog(LOG_ERR, "lcdproc: error allocating memory in asprintf"); + return; + } break; case 1: - asprintf(&TrackDescription, "%s (%s)", AudioTrack, tr("Left channel")); + if (asprintf(&TrackDescription, "%s (%s)", AudioTrack, tr("Left channel")) < 0) { + syslog(LOG_ERR, "lcdproc: error allocating memory in asprintf"); + return; + } break; case 2: - asprintf(&TrackDescription, "%s (%s)", AudioTrack, tr("Right channel")); + if (asprintf(&TrackDescription, "%s (%s)", AudioTrack, tr("Right channel")) < 0) { + syslog(LOG_ERR, "lcdproc: error allocating memory in asprintf"); + return; + } break; default: return; -- cgit v1.2.3