From: Ulya Trofimovich Date: Thu, 3 Aug 2017 10:52:49 +0000 (+0100) Subject: Skeleton: fixed initialization of maximal path length. X-Git-Tag: 1.0~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc2495c6807dccbd7fa918fd866ae32194f01edb;p=re2c Skeleton: fixed initialization of maximal path length. Broken by commit fffb5932ee52127e03b9f7f5ccca83a421d69061. Path length were initialized with 0 instead 'DIST_ERROR', which caused incorrect calculation of maximal path length. This in turn caused errors in estimating the number of byted necessary to hold keys during data generation in skeleton. The resulting keys were one-byte while maximal path length was more than one byte, which (fortunately!) caused runtime errors in skeleton programs. Example of program that caused skeleton error: /*!re2c (@t [\x00] [^]{5,6})* {} */ The error was hidden for so long because in practice inputs that need more than one-byte keys are rare, and fuzzer sets 'ulimit -t 10' when running re2c, so most of such programs were simply aborted. Those that were not aborted still had a chance of estimating key size correctly. --- diff --git a/re2c/src/skeleton/maxpath.cc b/re2c/src/skeleton/maxpath.cc index c609c215..8fada329 100644 --- a/re2c/src/skeleton/maxpath.cc +++ b/re2c/src/skeleton/maxpath.cc @@ -54,7 +54,7 @@ static void calc_dist( uint32_t maxpath(const Skeleton &skel) { std::vector loops(skel.nodes_count); - std::vector dists(skel.nodes_count); + std::vector dists(skel.nodes_count, DIST_ERROR); calc_dist(skel, loops, dists, 0); const uint32_t maxlen = dists[0]; if (maxlen == DIST_MAX) {