I1401: Fixed possible NULL pointer dereference (COVERITY)

This commit is contained in:
Bob Supnik 2017-03-14 04:48:58 -07:00 committed by Mark Pizzolato
parent f586105051
commit aef66264de

View file

@ -1,6 +1,6 @@
/* i1401_sys.c: IBM 1401 simulator interface /* i1401_sys.c: IBM 1401 simulator interface
Copyright (c) 1993-2014, Robert M. Supnik Copyright (c) 1993-2017, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -23,6 +23,7 @@
used in advertising or otherwise to promote the sale, use or other dealings used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik. in this Software without prior written authorization from Robert M Supnik.
13-Mar-17 RMS Fixed possible dull dereference (COVERITY)
25-Mar-14 RMS Fixed d character printout (Van Snyder) 25-Mar-14 RMS Fixed d character printout (Van Snyder)
25-Mar-12 RMS Fixed && -> & in test (Peter Schorn) 25-Mar-12 RMS Fixed && -> & in test (Peter Schorn)
20-Sep-05 RMS Revised for new code tables 20-Sep-05 RMS Revised for new code tables
@ -362,8 +363,11 @@ int32 i, op, ilnt, t, cflag, wm_seen;
int32 wmch = conv_old? '~': '`'; int32 wmch = conv_old? '~': '`';
char gbuf[CBUFSIZE]; char gbuf[CBUFSIZE];
cflag = (uptr == NULL) || (uptr == &cpu_unit); if (uptr == NULL)
while (isspace (*cptr)) cptr++; /* absorb spaces */ uptr = &cpu_unit;
cflag = (uptr == &cpu_unit); /* CPU flag */
while (isspace (*cptr)) /* absorb spaces */
cptr++;
if ((sw & SWMASK ('C')) || (sw & SWMASK ('S')) || (*cptr == wmch) || if ((sw & SWMASK ('C')) || (sw & SWMASK ('S')) || (*cptr == wmch) ||
((*cptr == '\'') && cptr++) || ((*cptr == '"') && cptr++)) { ((*cptr == '\'') && cptr++) || ((*cptr == '"') && cptr++)) {
wm_seen = 0; wm_seen = 0;