As ca_list_size is used in malloc, ensure that ca_list_size > 0.
If ca_list_size > 0, then ca_list cannot be NULL. Make these
assumptions explicit with argument condition check.
Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
int ca_list_size)
{
int ret, i, j;
- gnutls_x509_crt_t *new_list = gnutls_malloc(ca_list_size * sizeof(gnutls_x509_crt_t));
+ gnutls_x509_crt_t *new_list;
+ if (ca_list == NULL || ca_list_size < 1)
+ return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
+
+ new_list = gnutls_malloc(ca_list_size * sizeof(gnutls_x509_crt_t));
if (!new_list)
return GNUTLS_E_MEMORY_ERROR;