diff --git a/src/tarantool.c b/src/tarantool.c index 4121018..ba46c65 100644 --- a/src/tarantool.c +++ b/src/tarantool.c @@ -1513,7 +1513,7 @@ PHP_METHOD(Tarantool, update) { SSTR_LEN(obj->value) = before_len; RETURN_FALSE; } - php_tp_reencode_length(obj->value, sz); + php_tp_reencode_length(obj->value, before_len); if (tarantool_stream_send(obj) == FAILURE) RETURN_FALSE; @@ -1543,7 +1543,7 @@ PHP_METHOD(Tarantool, upsert) { SSTR_LEN(obj->value) = before_len; RETURN_FALSE; } - php_tp_reencode_length(obj->value, sz); + php_tp_reencode_length(obj->value, before_len); if (tarantool_stream_send(obj) == FAILURE) RETURN_FALSE; diff --git a/src/tarantool_proto.c b/src/tarantool_proto.c index b39e6cb..f8c69e5 100644 --- a/src/tarantool_proto.c +++ b/src/tarantool_proto.c @@ -268,9 +268,10 @@ void php_tp_encode_usplice(smart_string *str, uint32_t fieldno, php_mp_pack_string(str, buffer, buffer_len); } -void php_tp_reencode_length(smart_string *str, char *sz) { - ssize_t package_size = (SSTR_POS(str) - sz) - 5; +void php_tp_reencode_length(smart_string *str, size_t orig_len) { + ssize_t package_size = (SSTR_LEN(str) - orig_len) - 5; assert(package_size > 0); + char *sz = SSTR_BEG(str) + orig_len; php_mp_pack_package_size_basic(sz, package_size); } diff --git a/src/tarantool_proto.h b/src/tarantool_proto.h index 8470923..658d0fb 100644 --- a/src/tarantool_proto.h +++ b/src/tarantool_proto.h @@ -150,7 +150,7 @@ void php_tp_encode_uother(smart_string *str, char type, uint32_t fieldno, void php_tp_encode_usplice(smart_string *str, uint32_t fieldno, uint32_t position, uint32_t offset, const char *buffer, size_t buffer_len); -void php_tp_reencode_length(smart_string *str, char *sz); +void php_tp_reencode_length(smart_string *str, size_t orig_len); int convert_iter_str(const char *i, size_t i_len);