mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-19 09:31:36 +00:00
openssl_stream: fix memory leak when creating new stream
This commit is contained in:
parent
2afb6fa46d
commit
2baf854e97
@ -545,6 +545,7 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
|
|||||||
st = git__calloc(1, sizeof(openssl_stream));
|
st = git__calloc(1, sizeof(openssl_stream));
|
||||||
GITERR_CHECK_ALLOC(st);
|
GITERR_CHECK_ALLOC(st);
|
||||||
|
|
||||||
|
st->io = NULL;
|
||||||
#ifdef GIT_CURL
|
#ifdef GIT_CURL
|
||||||
error = git_curl_stream_new(&st->io, host, port);
|
error = git_curl_stream_new(&st->io, host, port);
|
||||||
#else
|
#else
|
||||||
@ -552,12 +553,13 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
goto out_err;
|
||||||
|
|
||||||
st->ssl = SSL_new(git__ssl_ctx);
|
st->ssl = SSL_new(git__ssl_ctx);
|
||||||
if (st->ssl == NULL) {
|
if (st->ssl == NULL) {
|
||||||
giterr_set(GITERR_SSL, "failed to create ssl object");
|
giterr_set(GITERR_SSL, "failed to create ssl object");
|
||||||
return -1;
|
error = -1;
|
||||||
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
st->host = git__strdup(host);
|
st->host = git__strdup(host);
|
||||||
@ -576,6 +578,12 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
|
|||||||
|
|
||||||
*out = (git_stream *) st;
|
*out = (git_stream *) st;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_err:
|
||||||
|
git_stream_free(st->io);
|
||||||
|
git__free(st);
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user