util: fixed place where we could look one byte past end of string
[ira/wip.git] / lib / util / charset / util_unistr.c
index 024dc70acc2748a22b5825b9616f8e46a0d4af5e..045aa4a3e3f4922a4df2c86d13e33425b5d05ae1 100644 (file)
@@ -483,7 +483,7 @@ _PUBLIC_ char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n)
                return NULL;
        }
 
-       while (*src && n--) {
+       while (n-- && *src) {
                size_t c_size;
                codepoint_t c = next_codepoint_convenience(iconv_convenience, src, &c_size);
                src += c_size;