diff --git a/skywalking.c b/skywalking.c index 39add8ba16e196a6034db992257bca0a5c2858ba..1bc60d6ca7909637e915fee18f848d85f9f1f378 100644 --- a/skywalking.c +++ b/skywalking.c @@ -241,7 +241,7 @@ ZEND_API void sky_execute_ex(zend_execute_data *execute_data) { if (Z_TYPE_P(arguments) == IS_ARRAY) { zend_ulong num_key; - zval *entry; + zval *entry, str_entry; smart_str command = {0}; smart_str_appends(&command, Z_STRVAL_P(id)); smart_str_appends(&command, " "); @@ -255,8 +255,9 @@ ZEND_API void sky_execute_ex(zend_execute_data *execute_data) { case IS_ARRAY: break; default: - convert_to_string(entry); - smart_str_appends(&command, Z_STRVAL_P(entry)); + ZVAL_COPY(&str_entry, entry); + convert_to_string(&str_entry); + smart_str_appends(&command, Z_STRVAL_P(&str_entry)); smart_str_appends(&command, " "); break; } @@ -557,18 +558,21 @@ ZEND_API void sky_execute_internal(zend_execute_data *execute_data, zval *return int is_string_command = 1; int i; for (i = 1; i < arg_count + 1; ++i) { + zval str_p; zval *p = ZEND_CALL_ARG(execute_data, i); if (Z_TYPE_P(p) == IS_ARRAY) { is_string_command = 0; break; } - if (Z_TYPE_P(p) != IS_STRING) { - convert_to_string(p); + + ZVAL_COPY(&str_p, p); + if (Z_TYPE_P(&str_p) != IS_STRING) { + convert_to_string(&str_p); } if (i == 1) { - add_assoc_string(&tags, "redis.key", Z_STRVAL_P(p)); + add_assoc_string(&tags, "redis.key", Z_STRVAL_P(&str_p)); } - smart_str_appends(&command, zend_str_tolower_dup(Z_STRVAL_P(p), Z_STRLEN_P(p))); + smart_str_appends(&command, zend_str_tolower_dup(Z_STRVAL_P(&str_p), Z_STRLEN_P(&str_p))); smart_str_appends(&command, " "); } // store command to tags diff --git a/src/go.mod b/src/go.mod index 33ffbcd07cd758727dc9a29e52e9f6cc9770fee7..caf3d019925b7c27d46597ea7651ed7f5e519df6 100644 --- a/src/go.mod +++ b/src/go.mod @@ -5,3 +5,4 @@ require ( github.com/google/uuid v1.1.1 google.golang.org/grpc v1.21.1 ) +