git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] hash: initialize context before cloning

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 19, 2026, 01:08 UTC
Message-ID
<20260719010842.17991-2-sandals@crustytoothpaste.net>
In-Reply-To
<20260719010842.17991-1-sandals@crustytoothpaste.net>

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>
---
 src/hash.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/hash.rs b/src/hash.rs
index dea2998de4..4d14e4b4fa 100644
--- a/src/hash.rs
+++ b/src/hash.rs
@@ -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,
Previous: brian m. carlsonNext: Jeff King
Message 3 of 4 in “Rust hash cleanups”
  1. 0/2 Rust hash cleanupsbrian m. carlson, Jul 19, 2026
  2. 2/2 rust: discard hash context when finishedbrian m. carlson, Jul 19, 2026
  3. 1/2 hash: initialize context before cloningbrian m. carlson, Jul 19, 2026
  4. Jeff KingJul 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.