hostkey.c: fix invalid memory access if libssh2_dsa_new fails
Reported by dimmaq, fixes #66
diff --git a/src/hostkey.c b/src/hostkey.c
index add4495..faad8c9 100644
--- a/src/hostkey.c
+++ b/src/hostkey.c
@@ -274,6 +274,8 @@
libssh2_dsa_ctx *dsactx;
const unsigned char *p, *q, *g, *y, *s;
unsigned long p_len, q_len, g_len, y_len, len;
+ int ret;
+
(void) hostkey_data_len;
if (*abstract) {
@@ -306,7 +308,11 @@
y = s;
/* s += y_len; */
- _libssh2_dsa_new(&dsactx, p, p_len, q, q_len, g, g_len, y, y_len, NULL, 0);
+ ret = _libssh2_dsa_new(&dsactx, p, p_len, q, q_len,
+ g, g_len, y, y_len, NULL, 0);
+ if (ret) {
+ return -1;
+ }
*abstract = dsactx;