thisistherk / fast_obj

Fast C OBJ parser
MIT License
636 stars 47 forks source link

Fix .obj parsing when empty 'g' is last #2

Closed zeux closed 5 years ago

zeux commented 5 years ago

In some .obj files, there's a stray 'g' followed by a newline at the very end of the file. What happens right now is that *p++ skips past the "terminating newline", and then proceeds to process out of bounds memory which leads to a crash.

I'm not sure if 'g' can actually be empty per spec, so this change just fixes the crash without resetting the group to "default" or anything like that; 'v'/'f' shouldn't be empty but this would fix crashing when parsing malicious/malformed .obj files as well.