Skip to content
This repository

Fixing serializer initialization and destruction in PHP 5.4 #191

Closed
wants to merge 1 commit into from

3 participants

Max Beutel Lars Strojny Michael Grunder
Max Beutel

The following patch fixes serializer initialization and destruction in PHP 5.4. This crashed the test suite if PHP Serializer is used for serialization.

Props again to @lstrojny actually he fixed it ;)

Lars Strojny

Can we get some feedback here?

Lars Strojny

ping

Michael Grunder
Collaborator

Doing some cleanup. This one is in. Closing :)

Michael Grunder michael-grunder closed this August 09, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 23, 2012
Max Beutel Fixing serializer initialization and destruction in PHP 5.4. 5de7124
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 0 deletions. Show diff stats Hide diff stats

  1. 10  library.c
10  library.c
@@ -1157,6 +1157,7 @@ redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_
1157 1157
 		case REDIS_SERIALIZER_PHP:
1158 1158
 
1159 1159
 #if ZEND_MODULE_API_NO >= 20100000
  1160
+			PHP_VAR_SERIALIZE_INIT(ht);
1160 1161
 #else
1161 1162
 			zend_hash_init(&ht, 10, NULL, NULL, 0);
1162 1163
 #endif
@@ -1164,6 +1165,7 @@ redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_
1164 1165
 			*val = sstr.c;
1165 1166
 			*val_len = (int)sstr.len;
1166 1167
 #if ZEND_MODULE_API_NO >= 20100000
  1168
+			PHP_VAR_SERIALIZE_DESTROY(ht);
1167 1169
 #else
1168 1170
 			zend_hash_destroy(&ht);
1169 1171
 #endif
@@ -1195,7 +1197,11 @@ redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval **re
1195 1197
 			if(!*return_value) {
1196 1198
 				MAKE_STD_ZVAL(*return_value);
1197 1199
 			}
  1200
+#if ZEND_MODULE_API_NO >= 20100000
  1201
+			PHP_VAR_UNSERIALIZE_INIT(var_hash);
  1202
+#else
1198 1203
 			memset(&var_hash, 0, sizeof(var_hash));
  1204
+#endif
1199 1205
 			if(!php_var_unserialize(return_value, (const unsigned char**)&val,
1200 1206
 					(const unsigned char*)val + val_len, &var_hash TSRMLS_CC)) {
1201 1207
 				efree(*return_value);
@@ -1203,7 +1209,11 @@ redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval **re
1203 1209
 			} else {
1204 1210
 				ret = 1;
1205 1211
 			}
  1212
+#if ZEND_MODULE_API_NO >= 20100000
  1213
+			PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
  1214
+#else
1206 1215
 			var_destroy(&var_hash);
  1216
+#endif
1207 1217
 
1208 1218
 			return ret;
1209 1219
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.