]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hash: initialize context before cloning
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 19 Jul 2026 01:08:41 +0000 (01:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Jul 2026 23:26:09 +0000 (16:26 -0700)
Our C-based clone helper requires that the context be initialized, but
we neglect to do that in our Clone implementation for CryptoHasher.
This does not matter when using our default block SHA-256
implementation, but it does cause a crash when using OpenSSL as the
backend.  Fix this by properly initializing the context before cloning
into it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
src/hash.rs

index dea2998de4cadd4c29fe8e6eb4ab557263e35adf..4d14e4b4fabc8bd02ed97b1809b8c66c27bc7309 100644 (file)
@@ -181,7 +181,10 @@ impl CryptoDigest for CryptoHasher {
 impl Clone for CryptoHasher {
     fn clone(&self) -> Self {
         let ctx = unsafe { c::git_hash_alloc() };
-        unsafe { c::git_hash_clone(ctx, self.ctx) };
+        unsafe {
+            c::git_hash_init(ctx, self.algo.hash_algo_ptr());
+            c::git_hash_clone(ctx, self.ctx)
+        };
         Self {
             algo: self.algo,
             ctx,