]> err.no Git - varnish/commitdiff
Fix a truly obscure bug in compiler message error reporting:
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 5 Oct 2008 22:28:13 +0000 (22:28 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 5 Oct 2008 22:28:13 +0000 (22:28 +0000)
If the error references the first token and there is no preceding
newline we would core dump.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3257 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvcl/vcc_token.c

index 093c317c9ae417601c8bc82e54dd246b7e33f5b9..787ed188066d162d35cc6f859702f985d3b34e22 100644 (file)
@@ -79,6 +79,8 @@ vcc_icoord(struct vsb *vsb, const struct token *t, const char **ll)
        pos = 0;
        sp = t->src;
        b = sp->b;
+       if (ll != NULL)
+               *ll = b;
        for (p = b; p < t->b; p++) {
                if (*p == '\n') {
                        lin++;
@@ -379,12 +381,13 @@ vcc_Lexer(struct tokenlist *tl, struct source *sp)
                        for (q = p + 2; q < sp->e; q++) {
                                if (*q == '}' && q[1] == 'C') {
                                        vcc_AddToken(tl, CSRC, p, q + 2);
-                                       p = q + 2;
                                        break;
                                }
                        }
-                       if (q < sp->e)
+                       if (q < sp->e) {
+                               p = q + 2;
                                continue;
+                       }
                        vcc_AddToken(tl, EOI, p, p + 2);
                        vsb_printf(tl->sb,
                            "Unterminated inline C source, starting at\n");