diff options
-rw-r--r-- | divelist.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/divelist.c b/divelist.c index e09eca5f9..910b0c909 100644 --- a/divelist.c +++ b/divelist.c @@ -788,12 +788,11 @@ static void get_string(char **str, const char *s) if (!s) s = ""; - len = strlen(s); + len = g_utf8_strlen(s, -1); if (len > 60) len = 60; - n = malloc(len+1); - memcpy(n, s, len); - n[len] = 0; + n = malloc(len * sizeof(gunichar) + 1); + g_utf8_strncpy(n, s, len); *str = n; } |