提交 01d0e241 编写于 作者: K Kurt Cancemi 提交者: Matt Caswell

crypto/x509/x509_vpm.c: Simplify int_x509_param_set1()

This change also avoids calling strlen twice when srclen is 0
Reviewed-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NMatt Caswell <matt@openssl.org>
上级 e2bb9b9b
...@@ -259,12 +259,11 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen, ...@@ -259,12 +259,11 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
{ {
void *tmp; void *tmp;
if (src) { if (src) {
if (srclen == 0) { if (srclen == 0)
tmp = OPENSSL_strdup(src);
srclen = strlen(src); srclen = strlen(src);
} else
tmp = OPENSSL_memdup(src, srclen); tmp = OPENSSL_memdup(src, srclen);
if (!tmp) if (tmp == NULL)
return 0; return 0;
} else { } else {
tmp = NULL; tmp = NULL;
...@@ -272,7 +271,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen, ...@@ -272,7 +271,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
} }
OPENSSL_free(*pdest); OPENSSL_free(*pdest);
*pdest = tmp; *pdest = tmp;
if (pdestlen) if (pdestlen != NULL)
*pdestlen = srclen; *pdestlen = srclen;
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册