test/evp_test.c: Add check for OPENSSL_strdup
As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.
@@ -1256,7 +1256,7 @@ static int mac_test_parse(EVP_TEST *t,
return parse_bin(value, &mdata->salt, &mdata->salt_len);
if (strcmp(keyword, "Algorithm") == 0) {
mdata->alg = OPENSSL_strdup(value);
- if (!mdata->alg)
+ if (mdata->alg == NULL)
return -1;
return 1;
}
@@ -1268,9 +1268,13 @@ static int mac_test_parse(EVP_TEST *t,
return mdata->xof = 1;
if (strcmp(keyword, "NoReinit") == 0)
return mdata->no_reinit = 1;
- if (strcmp(keyword, "Ctrl") == 0)
- return sk_OPENSSL_STRING_push(mdata->controls,
- OPENSSL_strdup(value)) != 0;
+ if (strcmp(keyword, "Ctrl") == 0) {
+ char *data = OPENSSL_strdup(value);
+
+ if (data == NULL)
+ return -1;
+ return sk_OPENSSL_STRING_push(mdata->controls, data) != 0;
+ }
if (strcmp(keyword, "OutputSize") == 0) {
mdata->output_size = atoi(value);
if (mdata->output_size < 0)
