X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=serializer.cpp;h=7d4ce119fceff9683584dbc8898682e1e9c9662e;hb=355ab0d214ee0f08fb44ebeafd70d5e93db84c10;hp=f20c304de54e690a5c41852127da93b6b8c3c2bb;hpb=73974b9b3e3deb6051fc01c0ea54b11530a90ee1;p=plocate diff --git a/serializer.cpp b/serializer.cpp index f20c304..7d4ce11 100644 --- a/serializer.cpp +++ b/serializer.cpp @@ -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.