From abcc0d370f44a44314b25cfec38651ac8920f70c Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Mon, 15 Dec 2014 00:10:54 +0100 Subject: [PATCH] agent.c: check return code of MapViewOfFile Fixes VS2012 code analysis warning C6387: 'p+4' may be '0': this does not adhere to the specification for the function 'memcpy': libssh2 agent.c 330 Fixes VS2012 code analysis warning C6387: 'p' may be '0': this does not adhere to the specification for the function 'UnmapViewOfFile': libssh2 agent.c 333 --- src/agent.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/agent.c b/src/agent.c index 92927b7..c203310 100644 --- a/src/agent.c +++ b/src/agent.c @@ -303,6 +303,12 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx) "failed setting up pageant filemap"); p2 = p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0); + if (p == NULL || p2 == NULL) { + CloseHandle(filemap); + return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL, + "failed to open pageant filemap for writing"); + } + _libssh2_store_str(&p2, (const char *)transctx->request, transctx->request_len);