From: cedric Date: Fri, 19 Oct 2012 01:47:28 +0000 (+0000) Subject: eina: don't segv in eina_unicode_utf8_get_next when index is NULL. X-Git-Tag: submit/2.0alpha-wayland/20121127.222009~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8c68190324d5fa20db5924e003351df15225b29;p=profile%2Fivi%2Feina.git eina: don't segv in eina_unicode_utf8_get_next when index is NULL. Patch by Patryk Kaczmarek git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@78215 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/include/eina_unicode.h b/src/include/eina_unicode.h index 1b3ed15..bd4ac1d 100644 --- a/src/include/eina_unicode.h +++ b/src/include/eina_unicode.h @@ -143,7 +143,7 @@ EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ * * @param buf the string * @param iindex the index to look at and return by. - * @return the codepoint found. + * @return the codepoint found, 0 if @p buf or @p iindex are NULL * @since 1.1.0 */ EAPI Eina_Unicode eina_unicode_utf8_get_prev(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2); diff --git a/src/lib/eina_unicode.c b/src/lib/eina_unicode.c index 7505906..a1993de 100644 --- a/src/lib/eina_unicode.c +++ b/src/lib/eina_unicode.c @@ -193,13 +193,15 @@ eina_unicode_escape(const Eina_Unicode *str) EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) { - int ind = *iindex; + int ind; Eina_Unicode r; unsigned char d; EINA_SAFETY_ON_NULL_RETURN_VAL(buf, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(iindex, 0); + ind = *iindex; + /* if this char is the null terminator, exit */ if ((d = buf[ind++]) == 0) return 0;