From b76ef4333a83e8f543411c578433d5db457788de Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 19 Feb 2011 14:59:30 +0000 Subject: Don't crash if there's no box associated with a textarea svn path=/trunk/netsurf/; revision=11711 --- render/form.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/render/form.c b/render/form.c index 6c703692a..3bf5bf550 100644 --- a/render/form.c +++ b/render/form.c @@ -629,6 +629,13 @@ char *form_textarea_value(struct form_control *textarea) char *value, *s; struct box *text_box; + /* Textarea may have no associated box if styled with display: none */ + if (textarea->box == NULL) { + /* Return the empty string: caller treats this as a + * non-successful control. */ + return strdup(""); + } + /* find required length */ for (text_box = textarea->box->children->children; text_box; text_box = text_box->next) { @@ -641,7 +648,8 @@ char *form_textarea_value(struct form_control *textarea) /* construct value */ s = value = malloc(len + 1); if (!s) - return 0; + return NULL; + for (text_box = textarea->box->children->children; text_box; text_box = text_box->next) { if (text_box->type == BOX_TEXT) { -- cgit v1.2.3