Skip to content

Commit 05272ea

Browse files
committed
Fix. Easy cleanup unref wrong reference
Fix. Read buffer use size_t as offset Change. Use httpbin.org as test server ```Lua -- Test case for easy:close() form = curl.form() e = curl.easy{httpheader = {}} e:close() form:free() ```
1 parent f9db68d commit 05272ea

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/lceasy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ static int lcurl_easy_cleanup(lua_State *L){
8787
p->rbuffer.ref = LUA_NOREF;
8888

8989
for(i = 0; i < LCURL_LIST_COUNT; ++i){
90-
luaL_unref(L, LCURL_LUA_REGISTRY, p->lists[i]);
9190
p->lists[i] = LUA_NOREF;
9291
}
9392

@@ -696,7 +695,7 @@ static size_t lcurl_read_callback(lua_State *L,
696695
assert(rbuffer->ref == LUA_NOREF);
697696

698697
n = lcurl_util_push_cb(L, rd);
699-
lua_pushnumber(L, ret);
698+
lua_pushinteger(L, ret);
700699
if(lua_pcall(L, n, LUA_MULTRET, 0)) return CURL_READFUNC_ABORT;
701700

702701
if(lua_isnoneornil(L, top + 1)){
@@ -786,7 +785,7 @@ static int lcurl_xferinfo_callback(void *arg, curl_off_t dltotal, curl_off_t dln
786785
if(lua_isboolean(L, top + 1))
787786
ret = lua_toboolean(L, top + 1)?0:1;
788787
else{
789-
ret = (size_t)lua_tonumber(L, top + 1);
788+
ret = lua_tointeger(L, top + 1);
790789
if(ret == 0) ret = 1; else ret = 0;
791790
}
792791
}

src/lcutils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ typedef struct lcurl_callback_tag{
1919
}lcurl_callback_t;
2020

2121
typedef struct lcurl_read_buffer_tag{
22-
int ref;
23-
int off;
22+
int ref;
23+
size_t off;
2424
}lcurl_read_buffer_t;
2525

2626
int lcurl_storage_init(lua_State *L);

test/test_pause02.c.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ local curl = require "lcurl"
55
-- i.e. 1 means that CURLPAUSE_CONT will be performed immediately after pause.)
66
local WAIT_COUNT = 32
77

8-
local RESOURCE_URL = "http://www.rfc-editor.org/rfc/rfc2543.txt"
8+
local SIZE = 100 * 1024
9+
local RESOURCE_URL = "http://httpbin.org/bytes/" .. SIZE
910

1011
local State = {
1112
PAUSE = 0, -- write function should return CURL_WRITEFUNC_PAUSE

0 commit comments

Comments
 (0)