From 724effcb47ebb713d3ef1776684b8f6407b4b6a5 Mon Sep 17 00:00:00 2001
From: ren mingshuai <78132473+rmsh1216@users.noreply.github.com>
Date: Sat, 1 Jul 2023 01:34:44 +0800
Subject: [PATCH] Add NULL pointer check for outlen before use (#1109)

Before assigning a value to the outlen, we need to check whether it is NULL.

Credit: Ren Mingshuai <renmingshuai@huawei.com>

Reference:https://github.com/libssh2/libssh2/commit/724effcb47ebb713d3ef1776684b8f6407b4b6a5
Conflict:NA
---
 src/misc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/misc.c b/src/misc.c
index b386e3d6..398457d4 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -901,7 +901,8 @@ int _libssh2_copy_string(LIBSSH2_SESSION *session, struct string_buf *buf,
         }
     }
     else {
-        *outlen = 0;
+        if(outlen)
+            *outlen = 0;
         *outbuf = NULL;
     }
 
-- 
2.27.0

