crypto/x509/x509_vpm.c: Simplify int_x509_param_set1()
authorKurt Cancemi <kurt@x64architecture.com>
Thu, 26 May 2016 20:38:31 +0000 (16:38 -0400)
committerMatt Caswell <matt@openssl.org>
Wed, 8 Jun 2016 14:30:03 +0000 (15:30 +0100)
This change also avoids calling strlen twice when srclen is 0

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/x509/x509_vpm.c

index f7ecdec8c56819f1d6e0b176e529eac472c7acec..194d09b36654617ddeb134bcfcd32a2d6aa6d9b0 100644 (file)
@@ -259,12 +259,11 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
 {
     void *tmp;
     if (src) {
-        if (srclen == 0) {
-            tmp = OPENSSL_strdup(src);
+        if (srclen == 0)
             srclen = strlen(src);
-        } else
-            tmp = OPENSSL_memdup(src, srclen);
-        if (!tmp)
+
+        tmp = OPENSSL_memdup(src, srclen);
+        if (tmp == NULL)
             return 0;
     } else {
         tmp = NULL;
@@ -272,7 +271,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
     }
     OPENSSL_free(*pdest);
     *pdest = tmp;
-    if (pdestlen)
+    if (pdestlen != NULL)
         *pdestlen = srclen;
     return 1;
 }