From 30b1f96fcf3a616e21122eef33584757b8dbde35 Mon Sep 17 00:00:00 2001 From: tb Date: Thu, 14 Dec 2023 18:12:51 +0000 Subject: [PATCH] OBJ_create: initialize buf and turn function into single exit --- lib/libcrypto/objects/obj_dat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index b58e8cfe949..600c3a66a60 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.75 2023/12/14 18:10:32 tb Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.76 2023/12/14 18:12:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -590,17 +590,17 @@ int OBJ_create(const char *oid, const char *sn, const char *ln) { ASN1_OBJECT *op = NULL; - unsigned char *buf; + unsigned char *buf = NULL; int len; int ret = 0; len = a2d_ASN1_OBJECT(NULL, 0, oid, -1); if (len <= 0) - return 0; + goto err; if ((buf = malloc(len)) == NULL) { OBJerror(ERR_R_MALLOC_FAILURE); - return 0; + goto err; } len = a2d_ASN1_OBJECT(buf, len, oid, -1); if (len == 0) @@ -613,6 +613,7 @@ OBJ_create(const char *oid, const char *sn, const char *ln) err: ASN1_OBJECT_free(op); free(buf); + return ret; } LCRYPTO_ALIAS(OBJ_create); -- 2.20.1