mirror of
https://github.com/Savapitech/42sh.git
synced 2026-03-18 21:50:35 +01:00
Fix malloc check
This commit is contained in:
@@ -171,9 +171,9 @@ int execute(char *buffer, env_t *env, history_t *history)
|
||||
return BUILTINS[i].ptr(env, args, buffer);
|
||||
path = get_env_value(env, "PATH");
|
||||
full_bin_path = find_binary(path, args[0]);
|
||||
U_DEBUG("Found bin [%s]\n", full_bin_path);
|
||||
if (full_bin_path == NULL)
|
||||
return (free((void *)args), RETURN_FAILURE);
|
||||
U_DEBUG("Found bin [%s]\n", full_bin_path);
|
||||
status = launch_bin(full_bin_path, args, env, buffer);
|
||||
status_handler(status, history);
|
||||
free(full_bin_path);
|
||||
|
||||
@@ -19,6 +19,8 @@ void *u_realloc(void *ptr, size_t actual_size, size_t new_size)
|
||||
if (!actual_size && !new_size)
|
||||
return NULL;
|
||||
new = malloc(new_size);
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
if (actual_size > 0 && new_size > 0)
|
||||
u_memcpy(new, ptr, actual_size);
|
||||
free(ptr);
|
||||
|
||||
@@ -16,6 +16,8 @@ char *u_strdup(char const *src)
|
||||
int len = u_strlen(src);
|
||||
|
||||
dest = malloc(sizeof(char) * (len + 1));
|
||||
if (dest == NULL)
|
||||
return NULL;
|
||||
u_bzero(dest, len + 1);
|
||||
return u_strcpy(dest, src);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user