Previously, qjs_webcrypto_key_make() returned without freeing the new
CryptoKey object when allocating its native data failed, deriveKey()
did not free the derived CryptoKey when allocating the output failed,
and the CryptoKey.algorithm getter did not free the hash name when
allocating the hash object failed. The values leaked; with debug
QuickJS the first two also triggered the gc_obj_list assertion in
JS_FreeRuntime().
Free the values on these paths.
The issue was introduced in
75ca26f8 (0.8.10).
k = js_malloc(cx, njs_max(length, 1));
if (k == NULL) {
+ JS_FreeValue(cx, dkey_value);
JS_ThrowOutOfMemory(cx);
return JS_EXCEPTION;
}
ret = JS_NewObject(cx);
if (JS_IsException(ret)) {
+ JS_FreeValue(cx, hash);
JS_FreeValue(cx, obj);
return JS_EXCEPTION;
}
k = js_mallocz(cx, sizeof(qjs_webcrypto_key_t));
if (k == NULL) {
+ JS_FreeValue(cx, key);
return JS_ThrowOutOfMemory(cx);
}