Fixed a use-after-free and array-overrun bugs in lexer.c
These didn't seem to trigger problems on Linux, but resulted
in memory exhaustion on OSX.
Merge pull request #630 from dthain/makeflow-bugs

Makeflow Crash Bugs Fixed