Hi Daniel,
Thank you for your feedback.
I have noticed the patch you mentioned. However, under the android(use bionic libc) environment, the bellowing condition maybe true which will cause a NULL pointer access to buffer. I add another one more condition to prevent it. This problem can also be reproduced by android.

diff --git a/src/lib.cpp b/src/lib.cpp
index 88fe5f3..8d1ca9f 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -285,7 +285,7 @@ void align_string(char *buffer, size_t min_sz, size_t max_sz)
        /* start with mbsrtowcs() local mbstate_t * and
         * NULL dst pointer*/
        sz = mbsrtowcs(NULL, (const char **)&buffer, max_sz, NULL);
-       if (sz == (size_t)-1) {
+       if ((sz == (size_t)-1) && (NULL != buffer)) {
                buffer[min_sz] = 0x00;
                return;
        }
--
1.7.9.5


On 7 July 2015 at 05:44, Daniel Leung <daniel.leung@linux.intel.com> wrote:
On Wed,  1 Jul 2015 19:52:24 +0800
Zhaoyang Huang <zhaoyang.huang@linaro.org> wrote:

> the buffer will be turn into NULL after invoking the mbsrtowcs function
> of bionic libc. Add a condition judgement for that
>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@linaro.org>
> ---
>  src/lib.cpp |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib.cpp b/src/lib.cpp
> index 88fe5f3..8d1ca9f 100644
> --- a/src/lib.cpp
> +++ b/src/lib.cpp
> @@ -285,7 +285,7 @@ void align_string(char *buffer, size_t min_sz, size_t max_sz)
>       /* start with mbsrtowcs() local mbstate_t * and
>        * NULL dst pointer*/
>       sz = mbsrtowcs(NULL, (const char **)&buffer, max_sz, NULL);
> -     if (sz == (size_t)-1) {
> +     if ((sz == (size_t)-1) && (NULL != buffer)) {
>               buffer[min_sz] = 0x00;
>               return;
>       }
> --
> 1.7.9.5
>

If you are on master branch, there is a patch (patches/android/prevent_segfaults.patch) to workaround the NULL pointer.

--
Daniel Leung <daniel.leung@linux.intel.com>