fix(git): fix resource leak in countCommits on exception

Replace RETURN_IF_EXCEPTION with explicit cleanup that frees the
git_revwalk before returning when toWTFString throws an exception.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Sosuke Suzuki
2026-02-04 13:54:24 +09:00
parent 48a6082167
commit a40e2b857e

View File

@@ -792,7 +792,10 @@ JSC_DEFINE_HOST_FUNCTION(jsGitRepositoryCountCommits, (JSC::JSGlobalObject * lex
}
WTF::String rangeString = rangeValue.toWTFString(lexicalGlobalObject);
RETURN_IF_EXCEPTION(scope, {});
if (scope.exception()) [[unlikely]] {
git_revwalk_free(walk);
return JSC::JSValue::encode(JSC::jsUndefined());
}
WTF::CString rangeCString = rangeString.utf8();
error = git_revwalk_push_range(walk, rangeCString.data());