]> granicus.if.org Git - re2c/commitdiff
Continued adding "--skeleton" switch.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 22 Apr 2015 16:54:48 +0000 (17:54 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 22 Apr 2015 16:54:48 +0000 (17:54 +0100)
Check possible overflow immediately.

re2c/skeleton.cc

index 8d9d30f80ba1bef0ea7220a90178dcfab4667ea3..cf62ec049b5a1fed96f54e1607885aae6c8623be 100644 (file)
@@ -112,10 +112,12 @@ uint32_t Skeleton::estimate_size_cover (SkeletonState * s, uint32_t count, uint3
                                        s->path_len = i->first->path_len + 1;
                                }
                                result += n;
+                               if (result > MAX_SIZE)
+                               {
+                                       return MAX_SIZE;
+                               }
                        }
-                       return result >= MAX_SIZE
-                               ? MAX_SIZE
-                               : result;
+                       return result;
                }
        }
        else