p is allocated by asprintf() in one of the *_from_tm() functions, so
it needs to be freed as in the other error path below.
CID 346194
ok jsing
-/* $OpenBSD: a_time_tm.c,v 1.18 2021/08/28 08:22:48 tb Exp $ */
+/* $OpenBSD: a_time_tm.c,v 1.19 2022/03/31 13:04:47 tb Exp $ */
/*
* Copyright (c) 2015 Bob Beck <beck@openbsd.org>
*
int allocated = 0;
struct tm tm;
size_t len;
- char * p;
+ char *p;
if (gmtime_r(&t, &tm) == NULL)
return (NULL);
}
if (s == NULL) {
- if ((s = ASN1_TIME_new()) == NULL)
+ if ((s = ASN1_TIME_new()) == NULL) {
+ free(p);
return (NULL);
+ }
allocated = 1;
}