Commit 979e1776a4dfdd90558c241369e756c0cbdbe33f

Thomas de Grivel 2023-07-10T10:46:59

bug caught on NetBSD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/libc3/str.c b/libc3/str.c
index cf18523..3557713 100644
--- a/libc3/str.c
+++ b/libc3/str.c
@@ -27,12 +27,11 @@ sw str_character (const s_str *str, uw position, character *dest)
 {
   character c;
   uw i = 0;
-  sw r;
+  sw r = 0;
   s_str s;
   s = *str;
   while (s.size > 0 && i <= position) {
-    r = str_read_character_utf8(&s, &c);
-    if (r <= 0)
+    if ((r = str_read_character_utf8(&s, &c)) <= 0)
       return -1;
     i++;
   }