summaryrefslogtreecommitdiff
path: root/libpiano/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-08-07 12:26:31 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-08-07 12:26:31 +0200
commit0cd2322d48c8889e47a0d5ee635503c19cb6fb2b (patch)
treefe6f6abbd4d90e914ed505c81ccdda77ab7bd0a0 /libpiano/src/main.c
parent3d7998a44299c69e7d721c4c5a20ddc32cec562b (diff)
downloadpianobar-0cd2322d48c8889e47a0d5ee635503c19cb6fb2b.tar.gz
pianobar-0cd2322d48c8889e47a0d5ee635503c19cb6fb2b.tar.bz2
pianobar-0cd2322d48c8889e47a0d5ee635503c19cb6fb2b.zip
piano: Check (m|c|re)alloc return value
Diffstat (limited to 'libpiano/src/main.c')
-rw-r--r--libpiano/src/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libpiano/src/main.c b/libpiano/src/main.c
index 01e055b..b3bcab8 100644
--- a/libpiano/src/main.c
+++ b/libpiano/src/main.c
@@ -390,7 +390,10 @@ PianoReturn_t PianoRenameStation (PianoHandle_t *ph, PianoStation_t *station,
char *urlencodedNewName, *xmlencodedNewName;
PianoReturn_t ret = PIANO_RET_ERR;
- xmlencodedNewName = PianoXmlEncodeString (newName);
+ if ((xmlencodedNewName = PianoXmlEncodeString (newName)) == NULL) {
+ return PIANO_RET_OUT_OF_MEMORY;
+ }
+
snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>"
"<methodCall><methodName>station.setStationName</methodName>"
"<params><param><value><int>%li</int></value></param>"
@@ -479,7 +482,10 @@ PianoReturn_t PianoSearchMusic (PianoHandle_t *ph,
char *xmlencodedSearchStr, *urlencodedSearchStr;
PianoReturn_t ret;
- xmlencodedSearchStr = PianoXmlEncodeString (searchStr);
+ if ((xmlencodedSearchStr = PianoXmlEncodeString (searchStr)) == NULL) {
+ return PIANO_RET_OUT_OF_MEMORY;
+ }
+
snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>"
"<methodCall><methodName>music.search</methodName>"
"<params><param><value><int>%li</int></value></param>"
@@ -810,7 +816,11 @@ const char *PianoErrorToStr (PianoReturn_t ret) {
break;
case PIANO_RET_STATION_NONEXISTENT:
- return "Station does not exist";
+ return "Station does not exist.";
+ break;
+
+ case PIANO_RET_OUT_OF_MEMORY:
+ return "Out of memory.";
break;
default: