Skip to content

Commit bfa84cc

Browse files
Jake ChampionJakeChampion
authored andcommitted
fix: free buf if an error has occured
1 parent 1ad8bed commit bfa84cc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

c-dependencies/js-compute-runtime/builtins/crypto-algorithm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,14 @@ namespace {
743743
// 2. If performing the operation results in an error, then throw an OperationError.
744744
// TODO: Change to an OperationError DOMException
745745
JS_ReportErrorUTF8(cx, "SubtleCrypto.digest: failed to create digest");
746+
JS_free(cx, buf);
746747
return nullptr;
747748
}
748749
// 3. Return a new ArrayBuffer containing result.
749750
JS::RootedObject array_buffer(cx);
750751
array_buffer.set(JS::NewArrayBufferWithContents(cx, size, buf));
751752
if (!array_buffer) {
753+
JS_free(cx, buf);
752754
JS_ReportOutOfMemory(cx);
753755
return nullptr;
754756
}

0 commit comments

Comments
 (0)