mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Avoid close of uninitialized socket in evbuffer unit test
Attempts to fix a crash bug found by Brodie Thiesfield.
This commit is contained in:
parent
caca2f451c
commit
bda21e7ff9
@ -595,7 +595,7 @@ test_evbuffer_add_file(void *ptr)
|
||||
const char *data = "this is what we add as file system data.";
|
||||
size_t datalen;
|
||||
const char *compare;
|
||||
evutil_socket_t fd, pair[2];
|
||||
evutil_socket_t fd = -1, pair[2] = {-1, -1};
|
||||
int r=0, n_written=0;
|
||||
|
||||
/* Add a test for a big file. XXXX */
|
||||
@ -647,7 +647,9 @@ test_evbuffer_add_file(void *ptr)
|
||||
|
||||
evbuffer_validate(src);
|
||||
end:
|
||||
if (pair[0] >= 0)
|
||||
evutil_closesocket(pair[0]);
|
||||
if (pair[1] >= 0)
|
||||
evutil_closesocket(pair[1]);
|
||||
evbuffer_free(src);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user