martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 259 forks source link

vis-lua.c: stop obj_ref_get() from leaving the lua stack modified #1116

Closed rnpnr closed 10 months ago

rnpnr commented 10 months ago

The only place where this behaviour was encountered was in file_lines_iterator() and it was just being worked around.

~~There was also likely a bug in the case that addr was NULL since 2 values would be popped from the stack instead of just 1. It is possible that the case is never hit though.~~

Edit: Ignore that last part. It would hit the lua_argerror() branch in that case.

mcepl commented 10 months ago

I have included it in https://git.sr.ht/~mcepl/vis and it seems to work just fine.

rnpnr commented 10 months ago

I updated my incorrect commit message and I'm going to apply this. The only place where the behaviour could be different is when using file:lines_iterator(). I tested before and after this patch and I see no difference in functionality. If this patch was incorrect that iterator would have broke because the upvalues in the C closure would have been off.