From 04aecb451d85b754e0bbd5113796180ac8946e30 Mon Sep 17 00:00:00 2001 From: raster Date: Tue, 28 Oct 2008 05:22:50 +0000 Subject: [PATCH] fix possible segv git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@37263 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_object_textblock.c | 79 +++++++++++++++++----------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index f155863..b605b4f 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -4026,13 +4026,14 @@ evas_textblock_cursor_range_delete(Evas_Textblock_Cursor *cur1, Evas_Textblock_C tcur.pos = evas_common_font_utf8_get_last((unsigned char *)tcur.node->text, tcur.node->len); else tcur.pos = 0; - } + } } } n1->text = _strbuf_remove(n1->text, cur1->pos, n1->len, &(n1->len), &(n1->alloc)); removes = NULL; for (l = (EINA_INLIST_GET(n1))->next; l != EINA_INLIST_GET(n2); l = l->next) removes = eina_list_append(removes, l); + format_hump = NULL; if (n1->type == NODE_TEXT) { if (!n1->text) @@ -4049,7 +4050,6 @@ evas_textblock_cursor_range_delete(Evas_Textblock_Cursor *cur1, Evas_Textblock_C free(n1); } } - format_hump = NULL; while (removes) { n = removes->data; @@ -4339,47 +4339,50 @@ evas_textblock_cursor_range_text_get(const Evas_Textblock_Cursor *cur1, const Ev if (format == EVAS_TEXTBLOCK_TEXT_MARKUP) { char *p, *ps, *pe; - - if ((n == n1) && (n == n2)) - { - ps = n->text + cur1->pos; - pe = ps + index - cur1->pos + 1; - } - else if (n == n1) - { - ps = n->text + cur1->pos; - pe = ps + strlen(ps); - } - else if (n == n2) - { - ps = n->text; - pe = ps + cur1->pos + 1; - } - else - { - ps = n->text; - pe = ps + strlen(ps); - } - p = ps; - while (p < pe) + + if (n->text) { - const char *escape; - int adv; - - escape = _escaped_char_match(p, &adv); - if (escape) + if ((n == n1) && (n == n2)) + { + ps = n->text + cur1->pos; + pe = ps + index - cur1->pos + 1; + } + else if (n == n1) { - p += adv; - txt = _strbuf_append(txt, escape, &txt_len, &txt_alloc); + ps = n->text + cur1->pos; + pe = ps + strlen(ps); + } + else if (n == n2) + { + ps = n->text; + pe = ps + cur1->pos + 1; } else { - char str[2]; + ps = n->text; + pe = ps + strlen(ps); + } + p = ps; + while (p < pe) + { + const char *escape; + int adv; - str[0] = *p; - str[1] = 0; - txt = _strbuf_append(txt, str, &txt_len, &txt_alloc); - p++; + escape = _escaped_char_match(p, &adv); + if (escape) + { + p += adv; + txt = _strbuf_append(txt, escape, &txt_len, &txt_alloc); + } + else + { + char str[2]; + + str[0] = *p; + str[1] = 0; + txt = _strbuf_append(txt, str, &txt_len, &txt_alloc); + p++; + } } } } @@ -4389,7 +4392,6 @@ evas_textblock_cursor_range_text_get(const Evas_Textblock_Cursor *cur1, const Ev { s += cur1->pos; txt = _strbuf_append_n(txt, s, index - cur1->pos, &txt_len, &txt_alloc); - } else if (n == n1) { @@ -4716,7 +4718,6 @@ evas_textblock_cursor_range_geometry_get(const Evas_Textblock_Cursor *cur1, cons line = evas_textblock_cursor_char_geometry_get(cur2, &cx, &cy, &cw, &ch); if (line < 0) { - free(tr); while (rects) { free(rects->data); -- 2.7.4