From: Behdad Esfahbod Date: Mon, 11 Apr 2011 17:27:30 +0000 (-0400) Subject: Make hb_tag_from_string(NULL) return HB_TAG_NONE X-Git-Tag: submit/2.0alpha-wayland/20121130.004132~9^2~388 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ff7401c9237cda661869c1cb196d685706ac4e9;p=profile%2Fivi%2Forg.tizen.video-player.git Make hb_tag_from_string(NULL) return HB_TAG_NONE --- diff --git a/src/hb-common.c b/src/hb-common.c index 3dfdbe8..90cba4e 100644 --- a/src/hb-common.c +++ b/src/hb-common.c @@ -35,6 +35,9 @@ hb_tag_from_string (const char *s) char tag[4]; unsigned int i; + if (!s) + return HB_TAG_NONE; + for (i = 0; i < 4 && s[i]; i++) tag[i] = s[i]; for (; i < 4; i++) diff --git a/test/test-types.c b/test/test-types.c index 0f32e42..eb13f13 100644 --- a/test/test-types.c +++ b/test/test-types.c @@ -83,6 +83,7 @@ static void test_types_tag (void) { g_assert_cmphex (HB_TAG_NONE, ==, 0); + g_assert_cmphex (HB_TAG ('a','B','c','D'), ==, 0x61426344); g_assert_cmphex (HB_TAG_CHAR4 ("aBcD"), ==, 0x61426344); @@ -93,6 +94,8 @@ test_types_tag (void) g_assert_cmphex (hb_tag_from_string ("aB"), ==, 0x61422020); g_assert_cmphex (hb_tag_from_string ("a"), ==, 0x61202020); g_assert_cmphex (hb_tag_from_string (""), ==, 0x20202020); + + g_assert_cmphex (hb_tag_from_string (NULL), ==, HB_TAG_NONE); } int