handle allocation failure in the previous commit

This commit is contained in:
Yashas 2017-09-30 09:33:47 +05:30 committed by GitHub
parent bd133697fd
commit 13314369a5

View File

@ -1494,10 +1494,14 @@ static int command(void)
lptr++; lptr++;
if (!SKIPPING) { if (!SKIPPING) {
char *usermsg=(char*)malloc(strlen(lptr)+1); char *usermsg=(char*)malloc(strlen(lptr)+1);
strcpy(usermsg,lptr); if(usermsg!=NULL) {
usermsg[strcspn(usermsg,"\r\n")]='\0'; strcpy(usermsg,lptr);
error(237,usermsg); /* user warning */ usermsg[strcspn(usermsg,"\r\n")]='\0';
free(usermsg); error(237,usermsg); /* user warning */
free(usermsg);
} else {
error(237,lptr);
} /* if */
} /* if */ } /* if */
break; break;
default: default: