From: j8takagi Date: Mon, 11 Feb 2019 14:29:48 +0000 (+0900) Subject: comet2monitorの修正 X-Git-Tag: v0.5p3~5 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=730611ebee687534d03ddfa6539b634a466e59fd;p=YACASL2.git comet2monitorの修正 --- diff --git a/src/monitor.c b/src/monitor.c index 831a47a..a921e8d 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -349,19 +349,20 @@ void monitor() buf = malloc_chk(MONINSIZE + 1, "monitor.buf"); fgets(buf, MONINSIZE, stdin); if((p = strchr(buf, '\n')) != NULL) { - strcpy(p, ""); + p = '\0'; } if((moncmdl = monlinetok(buf)) != NULL) { cmdtype = monitorcmd(moncmdl->cmd, moncmdl->args); free_moncmdline(moncmdl); } - FREE(buf); - if(cmdtype == MONQUIT) { + if(!buf[0] || cmdtype == MONQUIT) { + FREE(buf); shutdown(); freebps(); free_cmdtable(HASH_CODE); freecerr(); exit(0); } + FREE(buf); } while(cmdtype == MONREPEAT); } diff --git a/src/word.c b/src/word.c index d26438f..74a2786 100644 --- a/src/word.c +++ b/src/word.c @@ -84,6 +84,9 @@ WORD nh2word(const char *str) WORD w; assert(sizeof(WORD) * 8 == 16); /* WORD型のサイズが16ビットであることを確認 */ + if(str == NULL) { + return 0x0; + } if(!isdigit(*str) && *str != '-' && *str != '#') { setcerr(114, str); /* not integer */ return 0x0;