orangeduck / mpc

A Parser Combinator library for C
Other
2.67k stars 292 forks source link

Fix backtracing bug with mpc_parse_pipe #110

Closed nmeum closed 5 years ago

nmeum commented 5 years ago

I can't claim that I really understood this bug in its entirety but it seems to me that the pipe buffer is freed when no marks are left with the assumption that the original input can afterwards be read from the underlying stream which isn't the case on a pipe.

Before we free our buffer we therefore need to reset the underlying stream to its original state by pushing the buffer contents back onto the input stream.

Fixes #109

nmeum commented 5 years ago

@orangeduck any chance you could take a look at this? I've been using this patch for quite some time now and didn't run into any issues yet.

orangeduck commented 5 years ago

Thanks sorry I will try to take a look I've been very busy lately and it fell of my radar.

orangeduck commented 5 years ago

Thanks nmeum - a great fine and fix 👍