1
0
Fork 0

Add an assert in 'choice' command

Static analyzer indicates that in this context `rem` can be NULL,
therefore should not be passed to strchr, but in this context `rem`
cannot be NULL becasuse `args` is not NULL (even after StripSpaces).
This commit is contained in:
Patryk Obara 2019-12-27 15:46:28 +01:00 committed by Patryk Obara
parent a16543d2ee
commit 1bdb67b2c3

View file

@ -16,22 +16,23 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "dosbox.h"
#include "shell.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include "callback.h"
#include "regs.h"
#include "bios.h"
#include "../dos/drives.h"
#include "support.h"
#include "control.h"
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <vector>
#include <string>
#include <time.h>
static SHELL_Cmd cmd_list[]={
{ "DIR", 0, &DOS_Shell::CMD_DIR, "SHELL_CMD_DIR_HELP"},
@ -1329,7 +1330,10 @@ void DOS_Shell::CMD_CHOICE(char * args){
WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem);
return;
}
if (args == rem) args = strchr(rem,0)+1;
if (args == rem) {
assert(args);
args = strchr(rem, '\0') + 1;
}
if (rem) rem += 2;
if(rem && rem[0]==':') rem++; /* optional : after /c */
if (args > last) args = NULL;