]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
country: Fix SEGV when accessing the string pool
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 15 Oct 2019 13:30:05 +0000 (13:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 15 Oct 2019 13:30:05 +0000 (13:30 +0000)
This was caused because I am too stupid to count to two.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/country.c
src/loc/country.h

index d075bd7f15274bf3cb6243638680871ef7fc5f27..6e9bfaaa98a8bdf63694a30f63eda33483793ddd 100644 (file)
@@ -137,15 +137,12 @@ int loc_country_new_from_database_v0(struct loc_ctx* ctx, struct loc_stringpool*
                goto FAIL;
 
        // Set name
-#if 0
-       // XXX Reading from the stringpool makes test-country.c fail
        const char* name = loc_stringpool_get(pool, be32toh(dbobj->name));
        if (name) {
                r = loc_country_set_name(*country, name);
                if (r)
                        goto FAIL;
        }
-#endif
 
        return 0;
 
index b5fd9448403e3a5ec742f470da4a1a49448d825a..8d4ab23f192d710250e75766c809ca0de7d0bd9a 100644 (file)
@@ -49,7 +49,7 @@ static inline void loc_country_copy_code(char* dst, const char* src) {
     }
 
     // Terminate the string
-    dst[3] = '\0';
+    dst[2] = '\0';
 }
 
 #endif