From: Simon Josefsson Date: Thu, 28 Aug 2008 14:56:23 +0000 (+0200) Subject: Simplify logic. X-Git-Tag: gnutls_2_5_5~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b251146cb5b24daa964da3ca2541b0077b2c167e;p=thirdparty%2Fgnutls.git Simplify logic. --- diff --git a/lib/x509/common.c b/lib/x509/common.c index 495c649b7e..e890987ab2 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -325,6 +325,7 @@ _gnutls_x509_data2hex (const opaque * data, size_t data_size, { char *res; char escaped[MAX_STRING_LEN]; + unsigned int size; if (2 * data_size + 1 > MAX_STRING_LEN) { @@ -333,29 +334,24 @@ _gnutls_x509_data2hex (const opaque * data, size_t data_size, } res = _gnutls_bin2hex (data, data_size, escaped, sizeof (escaped)); - - if (res) + if (!res) { - unsigned int size = strlen (res) + 1; - if (size + 1 > *sizeof_out) - { - *sizeof_out = size; - return GNUTLS_E_SHORT_MEMORY_BUFFER; - } - *sizeof_out = size; /* -1 for the null +1 for the '#' */ - - if (out) - { - strcpy (out, "#"); - strcat (out, res); - } + gnutls_assert (); + return GNUTLS_E_INTERNAL_ERROR; + } - return 0; + size = strlen (res) + 1; + if (size + 1 > *sizeof_out) + { + *sizeof_out = size; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } - else + *sizeof_out = size; /* -1 for the null +1 for the '#' */ + + if (out) { - gnutls_assert (); - return GNUTLS_E_INTERNAL_ERROR; + strcpy (out, "#"); + strcat (out, res); } return 0;