@@ -226,12 +226,17 @@ static size_t php_dba_make_key(zval *key, char **key_str, char **key_free TSRMLS
226
226
* key_free = * key_str ;
227
227
return len ;
228
228
} else {
229
- * key_free = NULL ;
229
+ zval tmp = * key ;
230
+ int len ;
230
231
231
- convert_to_string ( key );
232
- * key_str = Z_STRVAL_P ( key );
232
+ zval_copy_ctor ( & tmp );
233
+ convert_to_string ( & tmp );
233
234
234
- return Z_STRLEN_P (key );
235
+ * key_free = * key_str = estrndup (Z_STRVAL (tmp ), Z_STRLEN (tmp ));
236
+ len = Z_STRLEN (tmp );
237
+
238
+ zval_dtor (& tmp );
239
+ return len ;
235
240
}
236
241
}
237
242
/* }}} */
@@ -297,6 +302,14 @@ static size_t php_dba_make_key(zval *key, char **key_str, char **key_free TSRMLS
297
302
RETURN_FALSE; \
298
303
}
299
304
305
+ /* the same check, but with a call to DBA_ID_DONE before returning */
306
+ #define DBA_WRITE_CHECK_WITH_ID \
307
+ if(info->mode != DBA_WRITER && info->mode != DBA_TRUNC && info->mode != DBA_CREAT) { \
308
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "You cannot perform a modification to a database without proper access"); \
309
+ DBA_ID_DONE; \
310
+ RETURN_FALSE; \
311
+ }
312
+
300
313
/* }}} */
301
314
302
315
/* {{{ globals */
@@ -557,7 +570,7 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
557
570
558
571
DBA_FETCH_RESOURCE (info , & id );
559
572
560
- DBA_WRITE_CHECK ;
573
+ DBA_WRITE_CHECK_WITH_ID ;
561
574
562
575
if (info -> hnd -> update (info , key_str , key_len , val , val_len , mode TSRMLS_CC ) == SUCCESS ) {
563
576
DBA_ID_DONE ;
@@ -1110,7 +1123,7 @@ PHP_FUNCTION(dba_delete)
1110
1123
{
1111
1124
DBA_ID_GET2 ;
1112
1125
1113
- DBA_WRITE_CHECK ;
1126
+ DBA_WRITE_CHECK_WITH_ID ;
1114
1127
1115
1128
if (info -> hnd -> delete (info , key_str , key_len TSRMLS_CC ) == SUCCESS )
1116
1129
{
0 commit comments