]> git.sesse.net Git - plocate/blobdiff - serializer.cpp
Work around brokenness in FreeBSD mbtowc().
[plocate] / serializer.cpp
index f20c304de54e690a5c41852127da93b6b8c3c2bb..7d4ce119fceff9683584dbc8898682e1e9c9662e 100644 (file)
@@ -60,7 +60,7 @@ void print_possibly_escaped(const string &str)
                        ptr += ret;
                        len -= ret;
                }
-       } while (all_safe);
+       } while (all_safe && *ptr != '\0');
 
        if (all_safe) {
                printf("%s\n", str.c_str());
@@ -77,7 +77,7 @@ void print_possibly_escaped(const string &str)
        mbtowc(nullptr, 0, 0);
        ptr = str.data();
        len = str.size();
-       for (;;) {
+       while (*ptr != '\0') {
                int ret = mbtowc(nullptr, ptr, len);
                if (ret == -1) {
                        // Malformed data.