diff options
| author | Tobias Schramm | 2018-08-03 21:39:21 +0000 |
|---|---|---|
| committer | Jo-Philipp Wich | 2018-08-03 21:46:06 +0000 |
| commit | ae1c656ff041c6f1ccb37b070fa261e0d71f2b12 (patch) | |
| tree | c4a6d68d9d5ce036d876376509076299e1e21e02 | |
| parent | eb850df45758be784b67b63dcbe31bd331c12483 (diff) | |
| download | uclient-ae1c656ff041c6f1ccb37b070fa261e0d71f2b12.tar.gz | |
uclient-http: Close ustream file handle only if allocated
Since the connection setup in uclient_do_connect can fail before
ustream_init_fd is called we must check the fd was actually allocated
before closing it, else we would close STDIN.
Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
| -rw-r--r-- | uclient-http.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/uclient-http.c b/uclient-http.c index ebe7758..8d6d327 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -149,7 +149,8 @@ static void uclient_http_disconnect(struct uclient_http *uh) if (uh->ssl) ustream_free(&uh->ussl.stream); ustream_free(&uh->ufd.stream); - close(uh->ufd.fd.fd); + if(uh->ufd.fd.fd) + close(uh->ufd.fd.fd); uh->us = NULL; } |