bug-libunistring
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-libunistring] Segmentation fault using u8_grapheme_prev with ma


From: Bruno Haible
Subject: Re: [bug-libunistring] Segmentation fault using u8_grapheme_prev with malformed UTF-8 string
Date: Thu, 16 Dec 2021 14:15:56 +0100

Hello Vincent,

> I have noticed a strange behavior using the function
> `u8_grapheme_prev`. Given a malformed UTF-8 string
> it causes a segmentation fault error.
> 
> -----------------------------------------------------
> 
> #include <string.h>
> #include <unigbrk.h>
> 
> int main()
> {
>      uint8_t *s = "foo\xff";      /* \xff invalid byte */
>      uint8_t *s_ = s + strlen(s);
>      const uint8_t *prev = u8_grapheme_prev(s_, s);
>      return 0;
> }
> 
> -----------------------------------------------------
> 
> $ gcc test.c -o test -lunistring
> $ ./test
> Segmentation fault (core dumped)
> $ echo $?
> 139
> 
> -----------------------------------------------------
> 
> OS: GNU/Linux (Manjaro)
> ARCH: x86_64
> libunistring: 0.9.10
> gcc: 11.1.0

Thanks for the report. This is a documentation bug. Fixed through
https://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=commitdiff;h=5c0e331cdde253593f31c14adbc26af3d9b256f0

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]