misc: remove unnecessary null pointer checks
Fixes: https://github.com/libuv/libuv/issues/595 PR-URL: https://github.com/libuv/libuv/pull/604 Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
f41b7386de
commit
81072b98f5
@ -39,10 +39,8 @@ int uv_dlopen(const char* filename, uv_lib_t* lib) {
|
||||
|
||||
|
||||
void uv_dlclose(uv_lib_t* lib) {
|
||||
if (lib->errmsg) {
|
||||
uv__free(lib->errmsg);
|
||||
lib->errmsg = NULL;
|
||||
}
|
||||
uv__free(lib->errmsg);
|
||||
lib->errmsg = NULL;
|
||||
|
||||
if (lib->handle) {
|
||||
/* Ignore errors. No good way to signal them without leaking memory. */
|
||||
@ -67,8 +65,7 @@ const char* uv_dlerror(const uv_lib_t* lib) {
|
||||
static int uv__dlerror(uv_lib_t* lib) {
|
||||
const char* errmsg;
|
||||
|
||||
if (lib->errmsg)
|
||||
uv__free(lib->errmsg);
|
||||
uv__free(lib->errmsg);
|
||||
|
||||
errmsg = dlerror();
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ char** uv_setup_args(int argc, char** argv) {
|
||||
int uv_set_process_title(const char* title) {
|
||||
int oid[4];
|
||||
|
||||
if (process_title) uv__free(process_title);
|
||||
uv__free(process_title);
|
||||
process_title = uv__strdup(title);
|
||||
|
||||
oid[0] = CTL_KERN;
|
||||
|
||||
@ -161,7 +161,7 @@ char** uv_setup_args(int argc, char** argv) {
|
||||
|
||||
|
||||
int uv_set_process_title(const char* title) {
|
||||
if (process_title) uv__free(process_title);
|
||||
uv__free(process_title);
|
||||
process_title = uv__strdup(title);
|
||||
setproctitle(title);
|
||||
return 0;
|
||||
|
||||
@ -109,10 +109,8 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
|
||||
req = container_of(w, uv_getaddrinfo_t, work_req);
|
||||
|
||||
/* release input parameter memory */
|
||||
if (req->alloc != NULL) {
|
||||
uv__free(req->alloc);
|
||||
req->alloc = NULL;
|
||||
}
|
||||
uv__free(req->alloc);
|
||||
req->alloc = NULL;
|
||||
|
||||
if (status == UV_ECANCELED) {
|
||||
assert(req->retcode == 0);
|
||||
@ -219,9 +217,7 @@ void uv_freeaddrinfo(struct addrinfo* ai) {
|
||||
char* alloc_ptr = (char*)ai;
|
||||
|
||||
/* release copied result memory */
|
||||
if (alloc_ptr != NULL) {
|
||||
uv__free(alloc_ptr);
|
||||
}
|
||||
uv__free(alloc_ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -354,8 +350,9 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
||||
}
|
||||
|
||||
error:
|
||||
if (req != NULL && req->alloc != NULL) {
|
||||
if (req != NULL) {
|
||||
uv__free(req->alloc);
|
||||
req->alloc = NULL;
|
||||
}
|
||||
return uv_translate_sys_error(err);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user