Skip to content

Commit d17a913

Browse files
committed
gbuteyko/vkext_upload_crash_0
1 parent 2132126 commit d17a913

7 files changed

Lines changed: 35 additions & 7 deletions

File tree

vkext/vk_zend.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@ static zend_always_inline void vk_zend_update_public_property_long(zval *object,
226226
#endif
227227
}
228228

229+
static zend_always_inline void vk_zend_call_known_instance_method(zval *object,
230+
const char * name, size_t name_len, zval *retval_ptr,
231+
uint32_t param_count, zval *params) {
232+
zend_object* zobj = Z_OBJ_P(object);
233+
zend_string* method_name = zend_string_init(name, name_len, 0);
234+
zend_function* fun = Z_OBJ_HANDLER_P(object, get_method)(&zobj, method_name, 0);
235+
zend_string_release(method_name);
236+
if (!fun) {
237+
return; // retval stays UNDEF
238+
}
239+
#if PHP_MAJOR_VERSION >= 8
240+
zend_call_known_instance_method(fun, zobj, retval_ptr, param_count, params);
241+
#else
242+
zval method_name_zval;
243+
ZVAL_STR(&method_name_zval, method_name);
244+
call_user_function(NULL, object, &method_name_zval, retval_ptr, param_count, params);
245+
#endif
246+
}
247+
229248
#define ZAPI_TO_PP(az) (&(az))
230249
#define ZP_TO_API_P(az) (az)
231250
#define SMART_STRDATA(ss) ((ss).s)

vkext/vkext-rpc-req-error.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ void tl::RpcReqError::tl_fetch() {
6868
}
6969

7070
void RpcError::try_fetch() {
71-
int op = tl_parse_int();
71+
int op = tl_lookup_int();
7272
if (op == TL_REQ_RESULT_HEADER) {
73+
(void)tl_parse_int(); // skip op
7374
flags = tl_parse_int();
7475
header.emplace().tl_fetch(flags);
75-
op = tl_parse_int();
76+
op = tl_lookup_int();
7677
}
7778
if (op == TL_RPC_REQ_ERROR) {
79+
(void)tl_parse_int(); // skip op
7880
error.emplace().tl_fetch();
7981
}
8082
}

vkext/vkext-rpc.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,7 @@ static struct rpc_query *rpc_query_alloc(double timeout) {
854854
q->qid = qid;
855855
q->start_time = precise_now;
856856
q->timeout = timeout;
857-
if (tl_current_function_name) {
858-
q->fun_name = tl_current_function_name;
859-
}
857+
q->fun_name = tl_current_function_name;
860858
/* ADD_CNT(tree_insert);
861859
START_TICKS(tree_insert);
862860
query_tree = tree_insert_query (query_tree, q, lrand48 ());

vkext/vkext-rpc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define RPC_BUF_SIZE (1 << 12)
1313
#define RPC_SERVER_MAGIC 0x8940303d
1414
#define RPC_BUFFER_MAGIC 0x8fa0da0c
15-
#define RPC_MAX_QUERY_LEN (1 << 24)
15+
#define RPC_MAX_QUERY_LEN ((1 << 24) - 1)
1616

1717
#define RPC_SKIP 0
1818

vkext/vkext-tl-parse.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ int tl_parse_int() {
2727
return do_rpc_fetch_int(&tl.error);
2828
}
2929

30+
int tl_lookup_int() {
31+
if (tl.error) {
32+
return -1;
33+
}
34+
return do_rpc_lookup_int(&tl.error);
35+
}
36+
3037
long long tl_parse_long() {
3138
if (tl.error) {
3239
return -1;
@@ -90,6 +97,7 @@ std::string tl_parse_string() {
9097
return res;
9198
}
9299
res.assign(s);
100+
free(s);
93101
return res;
94102
}
95103

vkext/vkext-tl-parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
void tl_parse_init();
1111
int tl_parse_int();
12+
int tl_lookup_int();
1213
long long tl_parse_long();
1314
double tl_parse_double();
1415
float tl_parse_float();

vkext/vkext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "vkext/vk_zend.h"
99

10-
#define VKEXT_VERSION "1.02"
10+
#define VKEXT_VERSION "1.02-upload-crash-0"
1111

1212
#define VKEXT_NAME "vk_extension"
1313

0 commit comments

Comments
 (0)