]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Simplify logic.
authorSimon Josefsson <simon@josefsson.org>
Thu, 28 Aug 2008 14:56:23 +0000 (16:56 +0200)
committerSimon Josefsson <simon@josefsson.org>
Thu, 28 Aug 2008 14:56:23 +0000 (16:56 +0200)
lib/x509/common.c

index 495c649b7e8056141883ab7069d061c4b6c978e8..e890987ab2600980b6453fbaa8d5219873a361b3 100644 (file)
@@ -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;