Skip to content

Commit

Permalink
fix: free buf if an error has occured
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion committed Apr 14, 2023
1 parent 1ad8bed commit bfa84cc
Showing 1 changed file with 2 additions and 0 deletions.
Expand Up @@ -743,12 +743,14 @@ namespace {
// 2. If performing the operation results in an error, then throw an OperationError.
// TODO: Change to an OperationError DOMException
JS_ReportErrorUTF8(cx, "SubtleCrypto.digest: failed to create digest");
JS_free(cx, buf);
return nullptr;
}
// 3. Return a new ArrayBuffer containing result.
JS::RootedObject array_buffer(cx);
array_buffer.set(JS::NewArrayBufferWithContents(cx, size, buf));
if (!array_buffer) {
JS_free(cx, buf);
JS_ReportOutOfMemory(cx);
return nullptr;
}
Expand Down

0 comments on commit bfa84cc

Please sign in to comment.