Skip to content

Commit 09fb018

Browse files
committed
fix:panic error returns
1 parent 03d9e53 commit 09fb018

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

hash.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,10 @@ func (h *evpHash) Clone() (HashCloner, error) {
358358
panic(err)
359359
}
360360
if _, err := ossl.EVP_MD_CTX_copy_ex(h2.ctx, h.ctx); err != nil {
361-
ossl.EVP_MD_CTX_free(h2.ctx)
362361
panic(err)
363362
}
364363
h2.ctx2, err = ossl.EVP_MD_CTX_new()
365364
if err != nil {
366-
ossl.EVP_MD_CTX_free(h2.ctx)
367365
panic(err)
368366
}
369367
runtime.SetFinalizer(h2, (*evpHash).finalize)

hmac.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,10 @@ func (h *opensslHMAC) Clone() (HashCloner, error) {
251251
case 1:
252252
ctx2, err := ossl.HMAC_CTX_new()
253253
if err != nil {
254-
return nil, err
254+
panic(err)
255255
}
256256
if _, err := ossl.HMAC_CTX_copy(ctx2, h.ctx1.ctx); err != nil {
257-
ossl.HMAC_CTX_free(ctx2)
258-
return nil, err
257+
panic(err)
259258
}
260259
cl := &opensslHMAC{
261260
ctx1: hmacCtx1{ctx: ctx2},
@@ -268,11 +267,9 @@ func (h *opensslHMAC) Clone() (HashCloner, error) {
268267
case 3:
269268
ctx2, err := ossl.EVP_MAC_CTX_dup(h.ctx3.ctx)
270269
if err != nil {
271-
return nil, err
270+
panic(err)
272271
}
273272

274-
// For OpenSSL 3.0.0, 3.0.1, and 3.0.2 we need to copy the key
275-
// from the original context to the new one.
276273
cl := &opensslHMAC{
277274
ctx3: hmacCtx3{ctx: ctx2, key: slices.Clone(h.ctx3.key)},
278275
size: h.size,

0 commit comments

Comments
 (0)