aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/buffer2array.c8
-rw-r--r--src/interface.c14
2 files changed, 19 insertions, 3 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]);
}
diff --git a/src/interface.c b/src/interface.c
index b1f016bc3..2ef2fafe6 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -229,7 +229,8 @@ int interfaceReadInput(Interface * interface) {
argArrayLength = buffer2array(interface->buffer,&argArray);
if(interface->commandList) {
- if(strcmp(argArray[0],INTERFACE_LIST_MODE_END)==0) {
+ if(argArrayLength==0);
+ else if(strcmp(argArray[0],INTERFACE_LIST_MODE_END)==0) {
ListNode * node = interface->commandList->firstNode;
ret = 0;
@@ -273,14 +274,21 @@ int interfaceReadInput(Interface * interface) {
}
}
else {
- if(strcmp(argArray[0],INTERFACE_LIST_MODE_BEGIN)==0) {
+ if(argArrayLength &&
+ strcmp(argArray[0],
+ INTERFACE_LIST_MODE_BEGIN)==0)
+ {
interface->commandList = makeList(free);
interface->commandListSize =
sizeof(List);
ret = 1;
}
else {
- if(strcmp(argArray[0],INTERFACE_LIST_MODE_END)==0) {
+ if(argArrayLength==0) ret = 0;
+ else if(strcmp(argArray[0],
+ INTERFACE_LIST_MODE_END)
+ ==0)
+ {
myfprintf(interface->fp,"%s not in command list mode\n",COMMAND_RESPOND_ERROR);
ret = -1;
}