提交 8c521c7a 编写于 作者: G Geoff Thorpe

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.
上级 77475142
......@@ -192,8 +192,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)
......@@ -313,7 +312,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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册