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:
parent
22083b182a
commit
1c27ce4e70
1 changed files with 2 additions and 3 deletions
|
@ -189,8 +189,7 @@ char *sk_delete(STACK *st, int loc)
|
||||||
char *ret;
|
char *ret;
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
if ((st == NULL) || (st->num == 0) || (loc < 0)
|
if(!st || (loc < 0) || (loc >= st->num)) return NULL;
|
||||||
|| (loc >= st->num)) return(NULL);
|
|
||||||
|
|
||||||
ret=st->data[loc];
|
ret=st->data[loc];
|
||||||
if (loc != st->num-1)
|
if (loc != st->num-1)
|
||||||
|
@ -310,7 +309,7 @@ char *sk_value(const STACK *st, int i)
|
||||||
|
|
||||||
char *sk_set(STACK *st, int i, char *value)
|
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);
|
return (st->data[i] = value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue