[lokisetup] [PATCH] double free bug
Stephane Peter
megastep at megastep.org
Wed Nov 17 15:27:10 EST 2004
Thanks, I just applied these patches.
On Nov 17, 2004, at 10:08 AM, Ludwig Nussel wrote:
> Hi,
>
> A double free bug and a small memleak slipped in:
>
> Index: loki_setup/install.c
> ===================================================================
> --- loki_setup.orig/install.c
> +++ loki_setup/install.c
> @@ -359,12 +359,10 @@ int GetProductPromptOverwrite(install_in
> static char check_deviant_paths(xmlNodePtr node, install_info *info,
> char* path_ret)
> {
> while ( node ) {
> - char *wanted;
> char *orig_dpath;
> const char *dpath;
>
> - wanted = xmlGetProp(node, "install");
> - if ( wanted && (strcmp(wanted, "true") == 0) ) {
> + if ( xmlNodePropIsTrue(node, "install") ) {
> xmlNodePtr elements = node->childs;
> while ( elements ) {
> dpath = orig_dpath = xmlGetProp(elements, "path");
> @@ -376,9 +374,9 @@ static char check_deviant_paths(xmlNodeP
> if ( path_up[0] != '/' ) { /* Not an absolute path */
> char buf[PATH_MAX];
> snprintf(buf, PATH_MAX, "%s/%s", info->install_path, path_up);
> - xmlFree(orig_dpath);
> if (!dir_is_accessible(buf))
> {
> + xmlFree(orig_dpath);
> if(path_ret) strcpy(path_ret, buf);
> return 1;
> }
> @@ -394,7 +392,6 @@ static char check_deviant_paths(xmlNodeP
> if (check_deviant_paths(node->childs, info, path_ret))
> return 1;
> }
> - xmlFree(wanted);
> node = node->next;
> }
> return 0;
>
>
> Prevent NULL deref when you want to debug the issue above and the
> glade file cannot be loaded :-):
>
> Index: loki_setup/gtk_ui.c
> ===================================================================
> --- loki_setup.orig/gtk_ui.c
> +++ loki_setup/gtk_ui.c
> @@ -1465,6 +1465,7 @@ static install_state gtkui_init(install_
> /* Glade segfaults if the file can't be read */
> opened = fopen(glade_file, "r");
> if ( opened == NULL ) {
> + fprintf(stderr, _("Unable to open %s, aborting!\n"),
> glade_file);
> return SETUP_ABORT;
> }
> fclose(opened);
> @@ -1860,7 +1861,7 @@ static void gtkui_abort(install_info *in
>
> /* No point in waiting for a change of state if the window is not
> there */
> w = glade_xml_get_widget(setup_glade, "setup_window");
> - if ( ! GTK_WIDGET_VISIBLE(w) )
> + if ( !w || ! GTK_WIDGET_VISIBLE(w) )
> return;
>
> if ( setup_glade ) {
>
> cu
> Ludwig
>
> --
> (o_ Ludwig.Nussel at gmx.de
> //\
> V_/_ PGP Key ID: FF8135CE
>
--
Stéphane Peter
megastep at megastep.org
More information about the Lokisetup
mailing list