Re: strippwd patch against CVS20041108



Hello Andrew,

I do have some questions about add_new_entry_cmd() in its current form.
Comments inlined in C99 style comments.

static void add_new_entry_cmd (void)
{
    char *title, *url, *to_free;
    int ret;

    /* Take current directory as default value for input fields */
    to_free = title = url = strip_password (g_strdup
(current_panel->cwd), 1);

// to_free, title and url now all point to the same string, right?
// They are not all duplicates?

    ret = add_new_entry_input (_("New hotlist entry"), _("Directory
label"),
			       _("Directory path"), "[Hotlist]", &title, &url);
    g_free (to_free);
// So this g_free() frees that string which is now invalid

    if (!ret)
	return;
    if (!title || !*title || !url || !*url) {
	g_free (title);
	g_free (url);
// But here you still g_free() both of them
	return;
    }

    if (ret == B_ENTER || ret == B_APPEND)
	add2hotlist (title, url, HL_TYPE_ENTRY, HL_AFTER_CURRENT);
    else
	add2hotlist (title, url, HL_TYPE_ENTRY, HL_BEFORE_CURRENT);

// And here you pass them as arguments.
    hotlist_state.modified = 1;
}

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]