From d2046e2cd0d57b425ca5da0266c9d7fcbb760417 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Fri, 22 Apr 2016 14:24:34 -0400 Subject: make sure type sizes never overflow --- parse.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index a06d5b9..272db45 100644 --- a/parse.c +++ b/parse.c @@ -818,7 +818,7 @@ parsetyp() t = nextnl(); } else { ty->dark = 0; - n = -1; + n = 0; sz = 0; al = 0; while (t != Trbrace) { @@ -836,10 +836,11 @@ parsetyp() al = a; if ((a = sz & (s-1))) { a = s - a; - if (++n < NSeg) { + if (n < NSeg) { /* padding segment */ ty->seg[n].ispad = 1; ty->seg[n].len = a; + n++; } } t = nextnl(); @@ -848,19 +849,19 @@ parsetyp() t = nextnl(); } else c = 1; - while (c-- > 0) { - if (++n < NSeg) { + while (c-- > 0) + if (n < NSeg) { ty->seg[n].isflt = flt; ty->seg[n].ispad = 0; ty->seg[n].len = s; + sz += a + s; + n++; } - sz += a + s; - } if (t != Tcomma) break; t = nextnl(); } - if (++n >= NSeg) + if (n >= NSeg) ty->dark = 1; else ty->seg[n].len = 0; -- cgit 1.4.1