unix: fix various memory leaks and undef behavior
Kindly suggested by `cppcheck`.
This commit is contained in:
parent
8094ac2129
commit
646de34f5e
@ -75,7 +75,7 @@ int uv_exepath(char* buffer, size_t* size) {
|
||||
result = _NSGetExecutablePath(buffer, &usize);
|
||||
if (result) return result;
|
||||
|
||||
path = (char*)malloc(2 * PATH_MAX);
|
||||
path = malloc(2 * PATH_MAX);
|
||||
fullpath = realpath(buffer, path);
|
||||
if (fullpath == NULL) {
|
||||
SAVE_ERRNO(free(path));
|
||||
|
||||
@ -590,7 +590,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
|
||||
|
||||
err = uv_mutex_init(&loop->cf_mutex);
|
||||
if (err)
|
||||
return err;
|
||||
goto fail_mutex_init;
|
||||
|
||||
err = uv_sem_init(&loop->cf_sem, 0);
|
||||
if (err)
|
||||
@ -660,6 +660,8 @@ fail_fsevent_sem_init:
|
||||
|
||||
fail_sem_init:
|
||||
uv_mutex_destroy(&loop->cf_mutex);
|
||||
|
||||
fail_mutex_init:
|
||||
free(state);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -348,6 +348,7 @@ static void uv__signal_event(uv_loop_t* loop,
|
||||
int r;
|
||||
|
||||
bytes = 0;
|
||||
end = 0;
|
||||
|
||||
do {
|
||||
r = read(loop->signal_pipefd[0], buf + bytes, sizeof(buf) - bytes);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user