evas: textblock - Added Null checking in evas_textblock_text_markup_to_utf8 before...
authorYoungbok Shin <youngb.shin@samsung.com>
Wed, 5 Feb 2014 13:23:55 +0000 (13:23 +0000)
committerTom Hacohen <tom@stosb.com>
Wed, 5 Feb 2014 13:23:55 +0000 (13:23 +0000)
Summary:
When input string has non-finished markup tags or escaped tags,
eina_strbuf_append_length is called with Null string.
There is a Null checking in eina_strbuf_* API, but it will print error message when input string is Null.
Strictly speaking, *_markup_to_utf8 API could be used with any kind of input string.
So, we need to add Null checking for removing the useless error message.

Test Plan:
Call the API like the following code.
evas_textblock_text_markup_to_utf8(NULL, "test_text&&&&");

ERR message will be printed.

Reviewers: woohyun, tasn, seoz, Hermet, hbr4570

CC: cedric
Differential Revision: https://phab.enlightenment.org/D493

src/lib/evas/canvas/evas_object_textblock.c

index 4ea0e26f1d63be239f1475c2e5f1b948095ec717..c2c1d06971642b9e49a1c93e691bca0e4512a636 100644 (file)
@@ -6557,8 +6557,15 @@ evas_textblock_text_markup_to_utf8(const Evas_Object *eo_obj, const char *text)
                }
              else if (*p == 0)
                {
-                  eina_strbuf_append_length(sbuf, s, p - s);
-                  s = NULL;
+                  if (s)
+                    {
+                       eina_strbuf_append_length(sbuf, s, p - s);
+                       s = NULL;
+                    }
+                  else
+                    {
+                       ERR("There is a invalid markup tag. Please check the text.");
+                    }
                }
              if (*p == 0)
                 break;
@@ -6571,8 +6578,15 @@ evas_textblock_text_markup_to_utf8(const Evas_Object *eo_obj, const char *text)
                    * mark the start of the tag */
                   tag_start = p;
                   tag_end = NULL;
-                  eina_strbuf_append_length(sbuf, s, p - s);
-                  s = NULL;
+                  if (s)
+                    {
+                       eina_strbuf_append_length(sbuf, s, p - s);
+                       s = NULL;
+                    }
+                  else
+                    {
+                       ERR("There is a invalid markup tag. Please check the text.");
+                    }
                }
           }
         else if (*p == '>')
@@ -6591,8 +6605,15 @@ evas_textblock_text_markup_to_utf8(const Evas_Object *eo_obj, const char *text)
                    * the start of the escape sequence */
                   esc_start = p;
                   esc_end = NULL;
-                  eina_strbuf_append_length(sbuf, s, p - s);
-                  s = NULL;
+                  if (s)
+                    {
+                       eina_strbuf_append_length(sbuf, s, p - s);
+                       s = NULL;
+                    }
+                  else
+                    {
+                       ERR("There is a invalid markup tag. Please check the text.");
+                    }
                }
           }
         else if (*p == ';')