diff -bpru dillo/src/html.c dillo.orig/src/html.c
--- dillo/src/html.c	Mon May 21 23:36:37 2001
+++ dillo.orig/src/html.c	Wed May 23 03:27:05 2001
@@ -116,20 +116,21 @@ static DilloHtmlLB *Html_lb_new(void)
 
 /*
  * Free the memory used by the linkblock
+ * Callback function from destroy signal (to avoid memory leaks)
  */
-static void Html_lb_free(void *D)
+static void Html_lb_destroy(GtkWidget *submit, DilloHtmlLB *html_lb)
 {
    gint i, j, k;
    DilloHtmlForm *form;
-   DilloHtmlLB *html_lb = D;
 
-   if (html_lb->NRef) {
+   if (html_lb->NRef > 1) {
       html_lb->NRef--;
       return;
    }
+
    for (i = 0; i < html_lb->num_forms; i++) {
       form = &html_lb->forms[i];
-      g_free(form->action);
+      a_Url_free(form->action);
       for (j = 0; j < form->num_inputs; j++) {
          g_free(form->inputs[j].name);
          g_free(form->inputs[j].init_str);
@@ -147,9 +148,7 @@ static void Html_lb_free(void *D)
 
    g_free(html_lb->forms);
 
-   if (html_lb->base_url)
       a_Url_free(html_lb->base_url);
-   html_lb->base_url = NULL;
    g_free(html_lb);
 }
 
@@ -1846,9 +1845,6 @@ static void Html_submit_form(GtkWidget *
    if ( (i = Html_find_form(submit, html_lb)) == -1 )
       return;
 
-   /* Increment reference use on html_lb */
-   html_lb->NRef++;
-
    form = &html_lb->forms[i];
    if ((form->method == DILLO_HTML_METHOD_GET) ||
        (form->method == DILLO_HTML_METHOD_POST)) {
@@ -1925,9 +1921,6 @@ static void Html_submit_form(GtkWidget *
    } else {
       g_print("Method unknown\n");
    }
-
-   /* Decrement use on html_lb */
-   Html_lb_free(html_lb);
 }
 
 /*
@@ -2086,7 +2079,11 @@ static void Html_tag_open_input(DilloHtm
 
    Html_add_input(form, inp_type, widget, name, init_str, NULL, init_val);
 
-   if (widget != NULL) {
+   if (widget) {
+      html_lb->NRef++;
+      gtk_signal_connect(GTK_OBJECT(widget), "destroy",
+			 GTK_SIGNAL_FUNC(Html_lb_destroy), html_lb);
+
       if(inp_type == DILLO_HTML_INPUT_TEXT || 
          inp_type == DILLO_HTML_INPUT_PASSWORD) {
          /*
@@ -3069,6 +3066,11 @@ static void Html_write(DilloHtml *html, 
 static void Html_close(DilloHtml *html, gint ClientKey)
 {
    gint i;
+
+   if (html->linkblock && html->linkblock->base_url) {
+      a_Url_free(html->linkblock->base_url);
+      html->linkblock->base_url = NULL;
+   }
 
    for (i = 0; i <= html->stack_top; i++) {
       g_free(html->stack[i].tag);
diff -bpru dillo/src/web.c dillo.orig/src/web.c
--- dillo/src/web.c	Sat May 12 21:00:02 2001
+++ dillo.orig/src/web.c	Wed May 23 03:26:00 2001
@@ -51,7 +51,7 @@ DwWidget* a_Web_dispatch_by_type (const 
    }
 
    /* Set the base_url in the linkblock */
-   if ( Web->url && Web->linkblock ) {
+   if ( Web->linkblock ) {
       if ( Web->linkblock->base_url )
          a_Url_free(Web->linkblock->base_url);
       Web->linkblock->base_url = a_Url_dup(Web->url);

