Skip to content

Commit 9726bc6

Browse files
committed
Duplicate possibly persistent string in phar metadata clone
1 parent b0d4d6e commit 9726bc6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/phar/phar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,14 @@ void phar_metadata_tracker_copy(phar_metadata_tracker *dest, const phar_metadata
688688
/* }}} */
689689

690690
/**
691-
* Increment reference counts after a metadata entry was copied
691+
* Copy constructor for a non-persistent clone.
692692
*/
693693
void phar_metadata_tracker_clone(phar_metadata_tracker *tracker) /* {{{ */
694694
{
695695
Z_TRY_ADDREF_P(&tracker->val);
696696
if (tracker->str) {
697-
tracker->str = zend_string_copy(tracker->str);
697+
/* Duplicate the string, as the original may have been persistent. */
698+
tracker->str = zend_string_dup(tracker->str, false);
698699
}
699700
}
700701
/* }}} */

0 commit comments

Comments
 (0)