fixed cmd malloc strlen()+1 bug

This commit is contained in:
douniwan5788 2013-02-05 17:27:21 +00:00
parent 04202e7aa7
commit 8ca5586d49

View file

@ -91,7 +91,7 @@ static void *main_loop(void *targ)
nl = strrchr(script_cmd_buf, '\n');
if (nl) *nl = '\0';
if ((cmd = (char*) malloc(strlen(script_cmd_buf))) != NULL)
if ((cmd = (char*) malloc(strlen(script_cmd_buf) + 1)) != NULL)
{
memset(cmd, 0, strlen(script_cmd_buf));
strcpy(cmd, script_cmd_buf);