Skip to content

Commit e56f916

Browse files
committed
Plug a memory leak in x509_name_encode()
This is nearly identical to a leak fixed by miod 10 years ago in x509_name_canon() but was missed in r1.30. This entire file needs a metric ton of bleach, but my head currently spins too much for tackling this, so go with the cheap one-liner. From Niels Dossche
1 parent 39200c1 commit e56f916

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/libcrypto/asn1/x_name.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: x_name.c,v 1.44 2024/07/08 14:48:49 beck Exp $ */
1+
/* $OpenBSD: x_name.c,v 1.45 2025/03/20 09:41:47 tb Exp $ */
22
/* Copyright (C) 1995-1998 Eric Young ([email protected])
33
* All rights reserved.
44
*
@@ -414,8 +414,10 @@ x509_name_encode(X509_NAME *a)
414414
if (!entries)
415415
goto memerr;
416416
if (!sk_STACK_OF_X509_NAME_ENTRY_push(intname.s,
417-
entries))
417+
entries)) {
418+
sk_X509_NAME_ENTRY_free(entries);
418419
goto memerr;
420+
}
419421
set = entry->set;
420422
}
421423
if (entries == NULL /* if entry->set is bogusly -1 */ ||

0 commit comments

Comments
 (0)