Pekka Lampila
2007-Nov-01 14:36 UTC
[Swfdec] libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie_html.c
libswfdec/swfdec_text_field_movie.c | 18 +++++++++++++++++ libswfdec/swfdec_text_field_movie_html.c | 32 +++++++++++++++++-------------- 2 files changed, 36 insertions(+), 14 deletions(-) New commits: commit e1f14212d5a236453dd64426cfde8e6646b526d7 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Thu Nov 1 16:32:52 2007 +0200 Don't crash in TextField when swfdec_text_format_new or _copy return NULL diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c index 4dd9c07..5d499b2 100644 --- a/libswfdec/swfdec_text_field_movie.c +++ b/libswfdec/swfdec_text_field_movie.c @@ -1063,6 +1063,10 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text, findex_new = g_new (SwfdecFormatIndex, 1); findex_new->index_ = end_index; findex_new->format = swfdec_text_format_copy (findex->format); + if (findex_new->format == NULL) { + g_free (findex_new); + break; + } iter = g_slist_insert (iter, findex_new, 1); } @@ -1071,6 +1075,10 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text, findex_new = g_new (SwfdecFormatIndex, 1); findex_new->index_ = start_index; findex_new->format = swfdec_text_format_copy (findex->format); + if (findex_new->format == NULL) { + g_free (findex_new); + break; + } swfdec_text_format_add (findex_new->format, format); iter = g_slist_insert (iter, findex_new, 1); @@ -1352,6 +1360,11 @@ swfdec_text_field_movie_set_text (SwfdecTextFieldMovie *text, const char *str, g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text)); g_return_if_fail (str != NULL); + if (text->format_new == NULL) { + text->input = g_string_truncate (text->input, 0); + return; + } + // remove old formatting info iter = text->formats; while (iter) { @@ -1368,6 +1381,11 @@ swfdec_text_field_movie_set_text (SwfdecTextFieldMovie *text, const char *str, block->index_ = 0; g_assert (SWFDEC_IS_TEXT_FORMAT (text->format_new)); block->format = swfdec_text_format_copy (text->format_new); + if (block->format == NULL) { + g_free (block); + text->input = g_string_truncate (text->input, 0); + return; + } text->formats = g_slist_prepend (text->formats, block); text->input_html = html; diff --git a/libswfdec/swfdec_text_field_movie_html.c b/libswfdec/swfdec_text_field_movie_html.c index ef22415..ba60530 100644 --- a/libswfdec/swfdec_text_field_movie_html.c +++ b/libswfdec/swfdec_text_field_movie_html.c @@ -352,19 +352,23 @@ swfdec_text_field_movie_html_parse_tag (ParserData *data, const char *p) data->tags_open = g_slist_prepend (data->tags_open, tag); // set format based on tag - object = SWFDEC_AS_OBJECT (tag->format); - SWFDEC_AS_VALUE_SET_BOOLEAN (&val, TRUE); - - if (tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) { - swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bullet, &val); - } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "b", 1)) { - swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bold, &val); - } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "i", 1)) { - swfdec_as_object_set_variable (object, SWFDEC_AS_STR_italic, &val); - } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "u", 1)) { - swfdec_as_object_set_variable (object, SWFDEC_AS_STR_underline, &val); - } else if (tag->name_length == 3 && !g_strncasecmp (tag->name, "img", 3)) { - SWFDEC_FIXME ("IMG tag support for TextField's HTML input missing"); + if (tag->format != NULL) { + object = SWFDEC_AS_OBJECT (tag->format); + SWFDEC_AS_VALUE_SET_BOOLEAN (&val, TRUE); + + if (tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) { + swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bullet, &val); + } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "b", 1)) { + swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bold, &val); + } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "i", 1)) { + swfdec_as_object_set_variable (object, SWFDEC_AS_STR_italic, &val); + } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "u", 1)) { + swfdec_as_object_set_variable (object, SWFDEC_AS_STR_underline, &val); + } + else if (tag->name_length == 3 && !g_strncasecmp (tag->name, "img", 3)) + { + SWFDEC_FIXME ("IMG tag support for TextField's HTML input missing"); + } } if (data->style_sheet && @@ -478,7 +482,7 @@ swfdec_text_field_movie_html_parse (SwfdecTextFieldMovie *text, const char *str) while (data.tags_closed != NULL) { ParserTag *tag = (ParserTag *)data.tags_closed->data; - if (tag->index != tag->end_index) { + if (tag->index != tag->end_index && tag->format != NULL) { swfdec_text_field_movie_set_text_format (text, tag->format, tag->index, tag->end_index); }
Reasonably Related Threads
- 20 commits - libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h
- 2 commits - libswfdec/swfdec_sound.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie_html.c
- 3 commits - libswfdec/swfdec_html_parser.c libswfdec/swfdec_text_field_movie.c
- 3 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_sprite_movie_as.c libswfdec/swfdec_text_field_movie.c
- 9 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_style_sheet.c libswfdec/swfdec_style_sheet.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie.h