summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-02-19 14:59:30 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-02-19 14:59:30 +0000
commitb76ef4333a83e8f543411c578433d5db457788de (patch)
tree356924eb50caaaca782dee5621ebb7c409b7c993
parentd8d0353a734767fcc1211b922820a59303e810a5 (diff)
downloadnetsurf-b76ef4333a83e8f543411c578433d5db457788de.tar.gz
netsurf-b76ef4333a83e8f543411c578433d5db457788de.tar.bz2
Don't crash if there's no box associated with a textarea
svn path=/trunk/netsurf/; revision=11711
-rw-r--r--render/form.c10
1 files changed, 9 insertions, 1 deletions
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) {