static JSValue
-qjs_fs_dirent_create(JSContext *cx, JSValueConst name, struct dirent *entry)
+qjs_fs_dirent_create(JSContext *cx, JSValue name, struct dirent *entry)
{
JSValue obj;
obj = JS_NewObjectClass(cx, QJS_CORE_CLASS_ID_FS_DIRENT);
if (JS_IsException(obj)) {
+ JS_FreeValue(cx, name);
return JS_EXCEPTION;
}
if (!types) {
if (JS_DefinePropertyValueUint32(cx, result, idx++, ename, 0) < 0) {
- JS_FreeValue(cx, ename);
JS_FreeValue(cx, result);
goto done;
}
} else {
v = qjs_fs_dirent_create(cx, ename, entry);
if (JS_IsException(v)) {
- JS_FreeValue(cx, ename);
JS_FreeValue(cx, result);
goto done;
}
if (JS_DefinePropertyValueUint32(cx, result, idx++, v, 0) < 0) {
- JS_FreeValue(cx, ename);
JS_FreeValue(cx, result);
goto done;
}
JS_PROP_C_W_E) < 0)
{
JS_FreeValue(cx, result);
- JS_FreeValue(cx, buffer);
result = JS_EXCEPTION;
goto done;
}
if (JS_IsUndefined(prev)) {
if (JS_SetProperty(cx, object, prop, value) < 0) {
+ value = JS_UNDEFINED;
goto exception;
}
JS_FreeValue(cx, length);
if (JS_SetPropertyUint32(cx, prev, len, value) < 0) {
+ value = JS_UNDEFINED;
goto exception;
}
JS_FreeValue(cx, prev);
+ prev = JS_UNDEFINED;
} else {
ret = JS_NewArray(cx);
}
if (JS_SetPropertyUint32(cx, ret, 0, prev) < 0) {
+ prev = JS_UNDEFINED;
JS_FreeValue(cx, ret);
goto exception;
}
prev = JS_UNDEFINED;
if (JS_SetPropertyUint32(cx, ret, 1, value) < 0) {
+ value = JS_UNDEFINED;
JS_FreeValue(cx, ret);
goto exception;
}
value = JS_UNDEFINED;
if (JS_SetProperty(cx, object, prop, ret) < 0) {
- JS_FreeValue(cx, ret);
goto exception;
}
}
static int qjs_webcrypto_generate_25519_keypair(JSContext *cx, int pkey_id,
qjs_webcrypto_key_t *wkey, qjs_webcrypto_algorithm_t *alg,
unsigned usage, int extractable, unsigned priv_usage,
- unsigned pub_usage, JSValue key, JSValue *obj_ret);
+ unsigned pub_usage, JSValue *key, JSValue *obj_ret);
#endif
static JSValue qjs_webcrypto_import_key(JSContext *cx, JSValueConst this_val,
int argc, JSValueConst *argv);
}
if (JS_DefinePropertyValueStr(cx, jwk, key, value, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, value);
return -1;
}
}
if (JS_DefinePropertyValueStr(cx, jwk, "alg", alg, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, alg);
goto fail;
}
if (JS_DefinePropertyValueStr(cx, jwk, "key_ops", ops, JS_PROP_C_W_E) < 0) {
JS_FreeValue(cx, jwk);
- JS_FreeValue(cx, ops);
return JS_EXCEPTION;
}
}
if (JS_DefinePropertyValueStr(cx, jwk, "k", val, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, val);
goto fail;
}
}
if (JS_DefinePropertyValueStr(cx, jwk, "alg", val, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, val);
goto fail;
}
}
if (JS_DefinePropertyValueStr(cx, jwk, "key_ops", val, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, val);
goto fail;
}
static int
qjs_webcrypto_generate_25519_keypair(JSContext *cx, int pkey_id,
qjs_webcrypto_key_t *wkey, qjs_webcrypto_algorithm_t *alg, unsigned usage,
- int extractable, unsigned priv_usage, unsigned pub_usage, JSValue key,
+ int extractable, unsigned priv_usage, unsigned pub_usage, JSValue *key,
JSValue *obj_ret)
{
JSValue keypub, obj;
return -1;
}
- if (JS_SetPropertyStr(cx, obj, "privateKey", key) < 0) {
+ if (JS_SetPropertyStr(cx, obj, "privateKey", *key) < 0) {
+ *key = JS_UNDEFINED;
JS_FreeValue(cx, keypub);
JS_FreeValue(cx, obj);
return -1;
}
+ *key = JS_UNDEFINED;
+
if (JS_SetPropertyStr(cx, obj, "publicKey", keypub) < 0) {
JS_FreeValue(cx, obj);
return -1;
options = argv[0];
key = JS_UNDEFINED;
keypub = JS_UNDEFINED;
+ obj = JS_UNDEFINED;
alg = qjs_key_algorithm(cx, options);
if (alg == NULL) {
}
if (JS_SetPropertyStr(cx, obj, "privateKey", key) < 0) {
+ key = JS_UNDEFINED;
goto fail;
}
key = JS_UNDEFINED;
if (JS_SetPropertyStr(cx, obj, "publicKey", keypub) < 0) {
+ keypub = JS_UNDEFINED;
goto fail;
}
}
if (JS_SetPropertyStr(cx, obj, "privateKey", key) < 0) {
+ key = JS_UNDEFINED;
goto fail;
}
key = JS_UNDEFINED;
if (JS_SetPropertyStr(cx, obj, "publicKey", keypub) < 0) {
+ keypub = JS_UNDEFINED;
goto fail;
}
extractable,
QJS_KEY_USAGE_SIGN,
QJS_KEY_USAGE_VERIFY,
- key, &obj);
+ &key, &obj);
if (n < 0) {
goto fail;
}
- key = JS_UNDEFINED;
break;
case QJS_ALGORITHM_X25519:
extractable,
QJS_KEY_USAGE_DERIVE_KEY
| QJS_KEY_USAGE_DERIVE_BITS,
- 0, key, &obj);
+ 0, &key, &obj);
if (n < 0) {
goto fail;
}
- key = JS_UNDEFINED;
break;
#endif
JS_FreeValue(cx, key);
JS_FreeValue(cx, keypub);
+ JS_FreeValue(cx, obj);
return qjs_promise_result(cx, JS_EXCEPTION);
}
JS_PROP_C_W_E)
< 0)
{
- JS_FreeValue(cx, pe);
JS_FreeValue(cx, obj);
return JS_EXCEPTION;
}
if (JS_DefinePropertyValueStr(cx, ret, "name", hash, JS_PROP_C_W_E)
< 0)
{
+ JS_FreeValue(cx, ret);
JS_FreeValue(cx, obj);
return JS_EXCEPTION;
}
if (JS_SetPropertyUint32(cx, ops, i++, value) < 0) {
JS_FreeValue(cx, ops);
- JS_FreeValue(cx, value);
return JS_EXCEPTION;
}
}
if (JS_SetPropertyUint32(cx, arr, i++, ret) < 0) {
JS_FreeValue(cx, arr);
- JS_FreeValue(cx, ret);
return JS_EXCEPTION;
}
}
return JS_EXCEPTION;
}
+ arr = JS_UNDEFINED;
+
if (JS_IsUndefined(prev)) {
if (JS_SetProperty(cx, args, key, val) < 0) {
+ val = JS_UNDEFINED;
goto exception;
}
length = JS_GetPropertyStr(cx, prev, "length");
if (JS_ToUint32(cx, &len, length)) {
+ JS_FreeValue(cx, length);
goto exception;
}
JS_FreeValue(cx, length);
if (JS_SetPropertyUint32(cx, prev, len, val) < 0) {
+ val = JS_UNDEFINED;
goto exception;
}
+ val = JS_UNDEFINED;
JS_FreeValue(cx, prev);
+ prev = JS_UNDEFINED;
} else {
}
if (JS_SetPropertyUint32(cx, arr, 0, prev) < 0) {
+ prev = JS_UNDEFINED;
goto exception;
}
+ prev = JS_UNDEFINED;
+
if (JS_SetPropertyUint32(cx, arr, 1, val) < 0) {
+ val = JS_UNDEFINED;
goto exception;
}
+ val = JS_UNDEFINED;
+
if (JS_SetProperty(cx, args, key, arr) < 0) {
+ arr = JS_UNDEFINED;
goto exception;
}
+
+ arr = JS_UNDEFINED;
}
JS_FreeAtom(cx, key);
JS_FreeAtom(cx, key);
JS_FreeValue(cx, val);
JS_FreeValue(cx, prev);
+ JS_FreeValue(cx, arr);
+ JS_FreeValue(cx, args);
return JS_EXCEPTION;
}
if (JS_DefinePropertyValueUint32(cx, array, n++, value, JS_PROP_C_W_E)
< 0)
{
- JS_FreeValue(cx, value);
JS_FreeCString(cx, name);
JS_FreeValue(cx, array);
return JS_EXCEPTION;
}
if (JS_SetPropertyStr(cx, object, "name", value) < 0) {
- JS_FreeValue(cx, value);
JS_FreeValue(cx, object);
return JS_EXCEPTION;
}
if (JS_DefinePropertyValueUint32(cx, array, idx++, elem,
JS_PROP_C_W_E) < 0)
{
- JS_FreeValue(cx, elem);
JS_FreeValue(cx, array);
return JS_EXCEPTION;
}
}
if (JS_DefinePropertyValueUint32(cx, elem, 0, key, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, key);
JS_FreeValue(cx, array);
return JS_EXCEPTION;
}
}
if (JS_DefinePropertyValueUint32(cx, elem, 1, val, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(cx, val);
JS_FreeValue(cx, array);
return JS_EXCEPTION;
}
if (JS_DefinePropertyValueUint32(cx, kv, 0, v, JS_PROP_C_W_E) < 0) {
ngx_rwlock_unlock(&dict->sh->rwlock);
- JS_FreeValue(cx, v);
JS_FreeValue(cx, kv);
JS_FreeValue(cx, arr);
return JS_EXCEPTION;
if (JS_DefinePropertyValueUint32(cx, kv, 1, v, JS_PROP_C_W_E) < 0) {
ngx_rwlock_unlock(&dict->sh->rwlock);
- JS_FreeValue(cx, v);
JS_FreeValue(cx, kv);
JS_FreeValue(cx, arr);
return JS_EXCEPTION;
if (JS_DefinePropertyValueUint32(cx, arr, i++, kv, JS_PROP_C_W_E) < 0) {
ngx_rwlock_unlock(&dict->sh->rwlock);
- JS_FreeValue(cx, kv);
JS_FreeValue(cx, arr);
return JS_EXCEPTION;
}
JS_PROP_C_W_E) < 0)
{
ngx_rwlock_unlock(&dict->sh->rwlock);
- JS_FreeValue(cx, key);
JS_FreeValue(cx, arr);
return JS_EXCEPTION;
}
if (JS_SetPropertyStr(cx, global_obj, "SharedMemoryError", shared_ctor)
< 0)
{
- JS_FreeValue(cx, shared_ctor);
JS_FreeValue(cx, global_obj);
return NULL;
}
if (JS_SetPropertyStr(fetch->cx, fetch->response_value, "message",
reason) < 0)
{
- JS_FreeValue(fetch->cx, reason);
goto done;
}
ret = JS_DefinePropertyValueUint32(cx, keys, n, item,
JS_PROP_C_W_E);
if (ret < 0) {
- JS_FreeValue(cx, item);
goto fail;
}
JS_PROP_C_W_E);
if (ret < 0) {
JS_FreeValue(cx, retval);
- JS_FreeValue(cx, value);
return JS_EXCEPTION;
}
if (JS_SetPropertyStr(cx, global_obj, classes[i]->class_name, class)
< 0)
{
- JS_FreeValue(cx, class);
JS_FreeValue(cx, proto);
JS_FreeValue(cx, global_obj);
return NULL;
}
if (JS_SetPropertyStr(cx, global, "njs", obj) < 0) {
- JS_FreeValue(cx, obj);
return -1;
}
ret = JS_DefinePropertyValue(ctx, obj, atom, str, JS_PROP_C_W_E);
JS_FreeAtom(ctx, atom);
if (ret < 0) {
-error:
- JS_FreeValue(ctx, name);
- JS_FreeValue(ctx, str);
- return JS_EXCEPTION;
+ str = JS_UNDEFINED;
+ goto error;
}
JS_FreeValue(ctx, name);
}
return obj;
+
+error:
+
+ JS_FreeValue(ctx, name);
+ JS_FreeValue(ctx, str);
+ JS_FreeValue(ctx, obj);
+
+ return JS_EXCEPTION;
}
}
if (JS_DefinePropertyValueUint32(ctx, val, i, str, JS_PROP_C_W_E) < 0) {
- JS_FreeValue(ctx, str);
JS_FreeValue(ctx, val);
return JS_EXCEPTION;
}
njs_nitems(qjs_process_proto));
if (JS_SetPropertyStr(ctx, obj, "argv", val) < 0) {
- JS_FreeValue(ctx, val);
+ JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}