mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
ECMAScript: Initialize jsval variables for return values
forms_item declared a variable (jsval val), passed its address to forms_item2, and set it as the return value. However, forms_item2 could return without initializing the jsval, especially if given too many arguments. Fix by initializing to JSVAL_VOID right away. I'm not sure that is the correct value to return in such cases, but at least it's better than risking a crash. Likewise in form_elements_item and form_elements_namedItem.
This commit is contained in:
parent
245df547ab
commit
465923e386
@ -770,7 +770,7 @@ form_elements_get_property(JSContext *ctx, JSObject *obj, jsid id, jsval *vp)
|
||||
static JSBool
|
||||
form_elements_item(JSContext *ctx, uintN argc, jsval *rval)
|
||||
{
|
||||
jsval val;
|
||||
jsval val = JSVAL_VOID;
|
||||
JSObject *obj = JS_THIS_OBJECT(ctx, rval);
|
||||
jsval *argv = JS_ARGV(ctx, rval);
|
||||
JSBool ret = form_elements_item2(ctx, obj, argc, argv, &val);
|
||||
@ -842,7 +842,7 @@ form_elements_item2(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsva
|
||||
static JSBool
|
||||
form_elements_namedItem(JSContext *ctx, uintN argc, jsval *rval)
|
||||
{
|
||||
jsval val;
|
||||
jsval val = JSVAL_VOID;
|
||||
JSObject *obj = JS_THIS_OBJECT(ctx, rval);
|
||||
jsval *argv = JS_ARGV(ctx, rval);
|
||||
JSBool ret = form_elements_namedItem2(ctx, obj, argc, argv, &val);
|
||||
@ -1470,7 +1470,7 @@ forms_get_property(JSContext *ctx, JSObject *obj, jsid id, jsval *vp)
|
||||
static JSBool
|
||||
forms_item(JSContext *ctx, uintN argc, jsval *rval)
|
||||
{
|
||||
jsval val;
|
||||
jsval val = JSVAL_VOID;
|
||||
JSObject *obj = JS_THIS_OBJECT(ctx, rval);
|
||||
jsval *argv = JS_ARGV(ctx, rval);
|
||||
JSBool ret = forms_item2(ctx, obj, argc, argv, &val);
|
||||
|
Loading…
Reference in New Issue
Block a user