summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2008-11-14 22:29:28 +0000
committerphintuka <phintuka>2008-11-14 22:29:28 +0000
commit6ca8893ed2c83a399f1a0d9f3dd7c1aef56c4988 (patch)
treeff934fd5f6ab8cce1a2d38a66b3866625617911a
parent27cd0d343be76d05115a66c29ed322e9381ec107 (diff)
downloadxineliboutput-6ca8893ed2c83a399f1a0d9f3dd7c1aef56c4988.tar.gz
xineliboutput-6ca8893ed2c83a399f1a0d9f3dd7c1aef56c4988.tar.bz2
Check asprintf return value
(Thanks to Rolf Ahrenberg)
-rw-r--r--menu.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/menu.c b/menu.c
index 6b5a709a..e86c7a46 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c,v 1.58 2008-11-01 07:23:00 phintuka Exp $
+ * $Id: menu.c,v 1.59 2008-11-14 22:29:28 phintuka Exp $
*
*/
@@ -277,11 +277,12 @@ eOSState cMenuBrowseFiles::Open(bool ForceOpen, bool Parent, bool Queue)
}
const char *d = GetCurrent()->Name();
char *buffer = NULL;
- asprintf(&buffer, "%s/%s", m_CurrentDir, d);
- while(buffer[0] == '/' && buffer[1] == '/')
- strcpy(buffer, buffer+1);
- free(m_CurrentDir);
- m_CurrentDir = buffer;
+ if(asprintf(&buffer, "%s/%s", m_CurrentDir, d) >= 0) {
+ while(buffer[0] == '/' && buffer[1] == '/')
+ strcpy(buffer, buffer+1);
+ free(m_CurrentDir);
+ m_CurrentDir = buffer;
+ }
Set();
return osContinue;
@@ -319,7 +320,8 @@ eOSState cMenuBrowseFiles::Open(bool ForceOpen, bool Parent, bool Queue)
if(it==Get(Current()))
index = i;
if(!it->IsDir())
- asprintf(&files[i++], "%s/%s", m_CurrentDir, it->Name());
+ if(asprintf(&files[i++], "%s/%s", m_CurrentDir, it->Name()) < 0)
+ i--;
}
cControl::Shutdown();
cControl::Launch(new cXinelibImagesControl(files, index, i));