diff --git a/src/publickey.c b/src/publickey.c index d49ec48d..36a60c14 100644 --- a/src/publickey.c +++ b/src/publickey.c @@ -941,7 +941,8 @@ int libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey, goto err_exit; } list = newlist; - memset(&list[keys], 0, (max_keys - keys) * sizeof(list[keys])); + memset(&list[keys], 0, + (max_keys - keys + 1) * sizeof(list[keys])); } if(pkey->version == 1) { unsigned long comment_len;