[bugfix] pic_get_args should ignore optional args when i > argc
This commit is contained in:
parent
b45d7d9592
commit
d696339577
11
src/vm.c
11
src/vm.c
|
@ -27,6 +27,11 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
|||
case '|':
|
||||
break;
|
||||
}
|
||||
|
||||
/* in order to run out of all arguments passed to this function
|
||||
(i.e. do va_arg for each argument), optional argument existence
|
||||
check is done in every case closure */
|
||||
|
||||
switch (c) {
|
||||
case '|':
|
||||
opt = true;
|
||||
|
@ -36,18 +41,22 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
|||
pic_value *p;
|
||||
|
||||
p = va_arg(ap, pic_value*);
|
||||
if (i < argc) {
|
||||
*p = GET_OPERAND(pic,i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
{
|
||||
double *f;
|
||||
|
||||
f = va_arg(ap, double *);
|
||||
if (i < argc) {
|
||||
*f = pic_float(GET_OPERAND(pic,i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
|
@ -57,11 +66,13 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
|||
|
||||
cstr = va_arg(ap, char **);
|
||||
len = va_arg(ap, size_t *);
|
||||
if (i < argc) {
|
||||
str = GET_OPERAND(pic,i);
|
||||
*cstr = pic_str_ptr(str)->str;
|
||||
*len = pic_str_ptr(str)->len;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue