Naji-k / minishell

1 stars 0 forks source link

str leak in handle_export_args #100

Closed srondss closed 1 year ago

srondss commented 1 year ago
char    **handle_export_args(char *simple_cmd, bool plus_equal)
{
    char    **key_value;
    char    *str;

    if (plus_equal == true)
    {
        key_value = ft_split(simple_cmd, '+');
        key_value[1] = ftp_substr(key_value[1], 0, ft_strlen(key_value[1]));
        str = ft_strjoin(key_value[0], key_value[1]);
        free_2d_arr(key_value);
    }
    else
        str = ft_strdup(simple_cmd); // !!!!!!!!!!!! this is leaking @naji. !!!!!!!!!!!!!!!!!!!!!!!
    key_value = ft_split(str, '=');
    key_value[0] = ftp_strjoin(key_value[0], "=");
    free(str); // !!!!!!!!!!!!!!   added this to stop leak, please remove comments if you agree. !!!!!!!!!!!!!!!!!
    return (key_value);
}
Naji-k commented 1 year ago

Yes agree thanks