소스 검색

small bug: a reader function should not modify the Lua stack

Roberto Ierusalimschy 13 년 전
부모
커밋
fc24a3a6c4
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      lbaselib.c

+ 2 - 1
lbaselib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.272 2011/11/30 12:42:21 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.273 2011/11/30 13:03:24 roberto Exp roberto $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -293,6 +293,7 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
   lua_pushvalue(L, 1);  /* get function */
   lua_call(L, 0, 1);  /* call it */
   if (lua_isnil(L, -1)) {
+    lua_pop(L, 1);  /* pop result */
     *size = 0;
     return NULL;
   }