aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer2array.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-31 16:15:09 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-31 16:15:09 +0000
commitf641d046fa8053a715fdfe70b570156ac4b6a953 (patch)
treee5eda0934be474e9de74ba1e5eafe384ebcc063d /src/buffer2array.c
parent9e382536dc74476e91966442a639cf437b2c22c0 (diff)
downloadmpd-f641d046fa8053a715fdfe70b570156ac4b6a953.tar.gz
mpd-f641d046fa8053a715fdfe70b570156ac4b6a953.tar.xz
mpd-f641d046fa8053a715fdfe70b570156ac4b6a953.zip
cleanup reading from interface, when argArrayLength returned by buffer2array
is 0, we weren't dealing with this well at all! git-svn-id: https://svn.musicpd.org/mpd/trunk@559 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/buffer2array.c')
-rw-r--r--src/buffer2array.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/buffer2array.c b/src/buffer2array.c
index 40247bde7..9ee67f17c 100644
--- a/src/buffer2array.c
+++ b/src/buffer2array.c
@@ -61,6 +61,12 @@ int buffer2array(char * origBuffer, char *** array) {
}
markArray[bufferLength] = '\0';
+ if(!count) {
+ free(buffer);
+ free(markArray);
+ return count;
+ }
+
beginArray = malloc(sizeof(int)*count);
(*array) = malloc(sizeof(char *)*count);
@@ -107,6 +113,8 @@ int buffer2array(char * origBuffer, char *** array) {
void freeArgArray(char ** array, int argArrayLength) {
int i;
+ if(argArrayLength==0) return;
+
for(i=0;i<argArrayLength;i++) {
free(array[i]);
}