From a9758da45a52bc8c630ec9493804d0c6ea30b24a Mon Sep 17 00:00:00 2001
From: Viktor Szakats <vszakats@users.noreply.github.com>
Date: Mon, 29 Jun 2026 19:12:21 +0200
Subject: [PATCH] publickey: fix potential arbitrary free in
 `libssh2_publickey_list_fetch()` (#2127)

Due to uninitialized list entry.

Reported-and-patch-by: Behzod Abdullayev
Reported-by: Sharique Raza

Follow-up to e15f5d97a04cc676ce117dd324fef85b046207a9
---
 src/publickey.c | 1 +
 1 file changed, 1 insertion(+)

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