Skip to content

Commit 010d8e4

Browse files
committed
Fixed possbile memleak
1 parent 09e29e6 commit 010d8e4

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

php_memcached_server.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,15 @@
2929

3030
#define MEMC_MAKE_ZVAL_COOKIE(my_zcookie, my_ptr) \
3131
do { \
32-
char *cookie_buf; \
33-
spprintf (&cookie_buf, 0, "%p", my_ptr); \
34-
MAKE_STD_ZVAL(my_zcookie); \
35-
ZVAL_STRING(my_zcookie, cookie_buf, 0); \
32+
zend_string *cookie_buf; \
33+
cookie_buf = zend_strpprintf(0, "%p", my_ptr); \
34+
ZVAL_STR(&my_zcookie, cookie_buf); \
3635
} while (0)
3736

3837
#define MEMC_MAKE_RESULT_CAS(my_zresult_cas, my_result_cas) \
3938
do { \
4039
my_result_cas = 0; \
41-
if (Z_TYPE_P(my_zresult_cas) != IS_NULL) { \
42-
convert_to_double (my_zresult_cas); \
43-
my_result_cas = (uint64_t) Z_DVAL_P(my_zresult_cas); \
44-
} \
40+
my_result_cas = zval_get_double(my_zresult_cas); \
4541
} while (0)
4642

4743

@@ -78,9 +74,7 @@ long s_invoke_php_callback (php_memc_server_cb_t *cb, zval ***params, ssize_t pa
7874
efree (buf);
7975
}
8076
if (retval_ptr) {
81-
convert_to_long (retval_ptr);
82-
retval = Z_LVAL_P(retval_ptr);
83-
zval_ptr_dtor(&retval_ptr);
77+
retval = zval_get_long(retval_ptr);
8478
}
8579
return retval;
8680
}
@@ -223,10 +217,7 @@ protocol_binary_response_status s_incr_decr_handler (php_memc_event_t event, con
223217

224218
retval = s_invoke_php_callback (&MEMC_GET_CB(event), params, 7);
225219

226-
if (Z_TYPE(zresult) != IS_LONG) {
227-
convert_to_long (&zresult);
228-
}
229-
*result = (uint64_t) Z_LVAL(zresult);
220+
*result = (uint64_t)zval_get_long(zresult);
230221

231222
MEMC_MAKE_RESULT_CAS(zresult_cas, *result_cas);
232223

0 commit comments

Comments
 (0)