diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2012-10-02 19:46:25 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-10-02 10:11:16 -0700 |
commit | 5468f19a0521efeda966eed2bc76a541232ee9be (patch) | |
tree | 8017a8dc3fe028d6dfd6653cff7bf23b5a4ee484 /packaging | |
parent | f2adb0cea638c6eeecc59e6879371a2409547ced (diff) | |
download | subsurface-5468f19a0521efeda966eed2bc76a541232ee9be.tar.gz |
Fixed potential, rare corruption of unicode characters
In divelist.c:get_string(), when truncating the string to a maximum
of 60 characters (to be shown in the divelist), make sure we are
counting in guinchar (sizeof usually 2) instead of gchar (sizeof usually 1).
Use Glib functions such as g_utf8_strlen() and g_utf8_strncpy() to do that.
This patch fixes the potential problem when truncating a UTF-8 string
by calculating its length using strlen() in bytes.
For char = 1 byte, if the length returned by strlen() is an odd number
this means there is at least one single byte length character in there.
But also if the same string has a UTF-8 character at exactly the truncate
position minus x(probably 1) bytes, we are going to split the bytes
forming said UTF-8 char resulting in an incorrect string.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'packaging')
0 files changed, 0 insertions, 0 deletions