knownhosts: Avoid possible memory leak on failed malloc

Thanks oss-fuzz

https://issues.oss-fuzz.com/issues/489362256

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Jakub Jelen
2026-03-04 17:37:39 +01:00
parent 5479b276b2
commit e7f4cc9580

View File

@@ -310,7 +310,11 @@ static int ssh_known_hosts_read_entries(const char *match,
}
}
if (entry != NULL) {
ssh_list_append(*entries, entry);
rc = ssh_list_append(*entries, entry);
if (rc != SSH_OK) {
ssh_knownhosts_entry_free(entry);
goto error;
}
}
}