From a3fac6529b5926986e6ab4c6a459a91af5bfbffb Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 22 Apr 2017 01:40:38 -0500 Subject: [PATCH] Fix to build with GCC --- src/ox/fs/test/tests.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ox/fs/test/tests.cpp b/src/ox/fs/test/tests.cpp index e2b0e555a..903efa69b 100644 --- a/src/ox/fs/test/tests.cpp +++ b/src/ox/fs/test/tests.cpp @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include #include #include #include @@ -24,11 +25,12 @@ map tests = { int retval = 0; string path = "/usr/share/charset.gbag"; PathIterator it(path.c_str(), path.size()); - const auto buffSize = path.size() + 1; + const auto buffSize = 1024; char buff[buffSize]; - retval |= !(it.next(buff, buffSize) == 0 && ox_strcmp(buff, "usr") == 0); - retval |= !(it.next(buff, buffSize) == 0 && ox_strcmp(buff, "share") == 0); - retval |= !(it.next(buff, buffSize) == 0 && ox_strcmp(buff, "charset.gbag") == 0); + assert(buffSize >= path.size()); + retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "usr") == 0); + retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "share") == 0); + retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "charset.gbag") == 0); return retval; } }, @@ -38,10 +40,11 @@ map tests = { int retval = 0; string path = "/usr/share/"; PathIterator it(path.c_str(), path.size()); - const auto buffSize = path.size() + 1; + const auto buffSize = 1024; char buff[buffSize]; - retval |= !(it.next(buff, buffSize) == 0 && ox_strcmp(buff, "usr") == 0); - retval |= !(it.next(buff, buffSize) == 0 && ox_strcmp(buff, "share") == 0); + assert(buffSize >= path.size()); + retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "usr") == 0); + retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "share") == 0); return retval; } }, @@ -51,9 +54,10 @@ map tests = { int retval = 0; string path = "/"; PathIterator it(path.c_str(), path.size()); - const auto buffSize = path.size() + 1; + const auto buffSize = 1024; char buff[buffSize]; - retval |= !(it.next(buff, buffSize) == 0 && ox_strcmp(buff, "\0") == 0); + assert(buffSize >= path.size()); + retval |= !(it.next(buff, path.size()) == 0 && ox_strcmp(buff, "\0") == 0); return retval; } },