Extend the index parameter checking from sk_value to sk_set(). Also tidy up

some similar code elsewhere.

Thanks to Francesco Petruzzi for bringing this to my attention.
This commit is contained in:
Geoff Thorpe 2004-04-21 15:09:25 +00:00
parent 8e94e99ccb
commit 688791b22b

View file

@ -191,8 +191,7 @@ char *sk_delete(STACK *st, int loc)
char *ret;
int i,j;
if ((st == NULL) || (st->num == 0) || (loc < 0)
|| (loc >= st->num)) return(NULL);
if(!st || (loc < 0) || (loc >= st->num)) return NULL;
ret=st->data[loc];
if (loc != st->num-1)
@ -312,7 +311,7 @@ char *sk_value(const STACK *st, int i)
char *sk_set(STACK *st, int i, char *value)
{
if(st == NULL) return NULL;
if(!st || (i < 0) || (i >= st->num)) return NULL;
return (st->data[i] = value);
}