Simon Josefsson wrote: > I can't think of any code that would have a problem with that change, so > +1, would you like to fix it?
OK, done as follows: 2025-11-23 Bruno Haible <[email protected]> crypto/gc: Improve the API of git_hash_clone. * lib/gc-gnulib.c (gc_hash_clone): Don't set *outhandle when failing. * lib/gc-libgcrypt.c (gc_hash_clone): Likewise. diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c index f91b439323..326dc9057a 100644 --- a/lib/gc-gnulib.c +++ b/lib/gc-gnulib.c @@ -630,12 +630,13 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle) _gc_hash_ctx *in = handle; _gc_hash_ctx *out; - *outhandle = out = calloc (1, sizeof (*out)); + out = calloc (1, sizeof (*out)); if (!out) return GC_MALLOC_ERROR; memcpy (out, in, sizeof (*out)); + *outhandle = out; return GC_OK; } diff --git a/lib/gc-libgcrypt.c b/lib/gc-libgcrypt.c index 86d6a3d482..4881f02cf4 100644 --- a/lib/gc-libgcrypt.c +++ b/lib/gc-libgcrypt.c @@ -372,7 +372,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle) _gc_hash_ctx *out; int err; - *outhandle = out = calloc (1, sizeof (*out)); + out = calloc (1, sizeof (*out)); if (!out) return GC_MALLOC_ERROR; @@ -385,6 +385,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle) return GC_INVALID_HASH; } + *outhandle = out; return GC_OK; }
