@@ -264,6 +264,7 @@ static void dba_close(dba_info *info)
264
264
}
265
265
ZEND_ASSERT (info -> path );
266
266
// Cannot use zend_string_release_ex(info->path, info->flags&DBA_PERSISTENT); as this fails GC assertion?
267
+ // Zend/zend_rc_debug.c:38: void ZEND_RC_MOD_CHECK(const zend_refcounted_h *): Assertion `(zval_gc_flags(p->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
267
268
zend_string_free (info -> path );
268
269
info -> path = NULL ;
269
270
@@ -456,6 +457,16 @@ static dba_info *php_dba_find(const zend_string *path)
456
457
}
457
458
/* }}} */
458
459
460
+ static zend_always_inline zend_string * php_dba_zend_string_dup_safe (zend_string * s , bool persistent )
461
+ {
462
+ if (ZSTR_IS_INTERNED (s ) && (!persistent || (GC_FLAGS (s ) & IS_STR_PERSISTENT ))) {
463
+ return s ;
464
+ } else {
465
+ return zend_string_init (ZSTR_VAL (s ), ZSTR_LEN (s ), persistent );
466
+ }
467
+ }
468
+
469
+
459
470
#define FREE_PERSISTENT_RESOURCE_KEY () if (persistent_resource_key) {zend_string_release_ex(persistent_resource_key, false);}
460
471
461
472
/* {{{ php_dba_open */
@@ -725,7 +736,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
725
736
726
737
info = pemalloc (sizeof (dba_info ), persistent );
727
738
memset (info , 0 , sizeof (dba_info ));
728
- info -> path = zend_string_dup (path , persistent );
739
+ info -> path = php_dba_zend_string_dup_safe (path , persistent );
729
740
info -> mode = modenr ;
730
741
info -> file_permission = permission ;
731
742
info -> map_size = map_size ;
@@ -777,8 +788,8 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
777
788
if (is_db_lock ) {
778
789
ZEND_ASSERT (opened_path );
779
790
/* replace the path info with the real path of the opened file */
780
- zend_string_release_ex (info -> path , persistent );
781
- info -> path = zend_string_dup (opened_path , persistent );
791
+ zend_string_release (info -> path );
792
+ info -> path = php_dba_zend_string_dup_safe (opened_path , persistent );
782
793
}
783
794
}
784
795
if (opened_path ) {
0 commit comments