lib/asn1: fix USE_AFTER_FREE in der_print_hex_heim_integer
Set *p to NULL on asprintf failure to prevent a dangling pointer and subsequent USE_AFTER_FREE when the caller ignores ENOMEM. Pair-Programmed-With: Dmitry Mikhalchenko <tascad@altlinux.org> Signed-off-by: Egor Mikhailov <mikhailovev@sgu.ru>
This commit is contained in:
committed by
Nico Williams
parent
9df6b9e13a
commit
afc4c486a1
@@ -97,8 +97,10 @@ der_print_hex_heim_integer (const heim_integer *data, char **p)
|
||||
if (data->negative) {
|
||||
len = asprintf(&q, "-%s", *p);
|
||||
free(*p);
|
||||
if (len < 0)
|
||||
if (len < 0) {
|
||||
*p = NULL;
|
||||
return ENOMEM;
|
||||
}
|
||||
*p = q;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user