summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2012-05-06 16:24:32 +0200
committerLars-Dominik Braun <lars@6xq.net>2012-05-06 16:24:32 +0200
commitf541c1fd4395814edd5efcdcb12ff317428d0030 (patch)
treef6dc6d03350a57eaa5be7ca7f29dd5c0dbaf64ce /src
parent0690a53ced01a19837a91c375cc9c44601d43066 (diff)
downloadpianobar-f541c1fd4395814edd5efcdcb12ff317428d0030.tar.gz
pianobar-f541c1fd4395814edd5efcdcb12ff317428d0030.tar.bz2
pianobar-f541c1fd4395814edd5efcdcb12ff317428d0030.zip
piano: Fix memory leak
Diffstat (limited to 'src')
-rw-r--r--src/libpiano/request.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libpiano/request.c b/src/libpiano/request.c
index 2e17872..7b73bc1 100644
--- a/src/libpiano/request.c
+++ b/src/libpiano/request.c
@@ -71,6 +71,7 @@ static const char *PianoAudioFormatToString (PianoAudioFormat_t format) {
*/
PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
PianoRequestType_t type) {
+ PianoReturn_t ret = PIANO_RET_OK;
const char *jsonSendBuf;
const char *method = NULL;
json_object *j = json_object_new_object ();
@@ -412,7 +413,6 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
case PIANO_REQUEST_RATE_SONG: {
/* love/ban song */
PianoRequestDataRateSong_t *reqData = req->data;
- PianoReturn_t pRet;
assert (reqData != NULL);
assert (reqData->song != NULL);
@@ -425,12 +425,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
req->data = &transformedReqData;
/* create request data (url, post data) */
- pRet = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
+ ret = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
/* and reset request type/data */
req->type = PIANO_REQUEST_RATE_SONG;
req->data = reqData;
- return pRet;
+ goto cleanup;
break;
}
@@ -438,7 +438,6 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
/* move song to a different station, needs two requests */
PianoRequestDataMoveSong_t *reqData = req->data;
PianoRequestDataAddFeedback_t transformedReqData;
- PianoReturn_t pRet;
assert (reqData != NULL);
assert (reqData->song != NULL);
@@ -462,12 +461,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
}
/* create request data (url, post data) */
- pRet = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
+ ret = PianoRequest (ph, req, PIANO_REQUEST_ADD_FEEDBACK);
/* and reset request type/data */
req->type = PIANO_REQUEST_MOVE_SONG;
req->data = reqData;
- return pRet;
+ goto cleanup;
break;
}
}
@@ -498,13 +497,15 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req,
if (encrypted) {
if ((req->postData = PianoEncryptString (ph->partner.out,
jsonSendBuf)) == NULL) {
- return PIANO_RET_OUT_OF_MEMORY;
+ ret = PIANO_RET_OUT_OF_MEMORY;
}
} else {
req->postData = strdup (jsonSendBuf);
}
+
+cleanup:
json_object_put (j);
- return PIANO_RET_OK;
+ return ret;
}