Skip to content

Commit 46561da

Browse files
committed
Fix leak in phar open
1 parent 96c84b7 commit 46561da

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

ext/phar/phar.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
13861386
mydata = ecalloc(1, sizeof(phar_archive_data));
13871387
mydata->fname = expand_filepath(fname, NULL);
13881388
if (mydata->fname == NULL) {
1389+
efree(mydata);
13891390
return FAILURE;
13901391
}
13911392
fname_len = strlen(mydata->fname);

ext/phar/tests/bug77396.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Bug #77396 Relative filename exceeding maximum path length causes null pointer d
55
--FILE--
66
<?php
77
$path = '../' . str_repeat("x", PHP_MAXPATHLEN) . '.tar';
8-
$phar = new PharData($path);
8+
try {
9+
$phar = new PharData($path);
10+
} catch (UnexpectedValueException $e) {
11+
echo $e->getMessage(), "\n";
12+
}
913
?>
10-
--EXPECTF--
11-
Fatal error: Uncaught UnexpectedValueException: Phar creation or opening failed in %s%ebug77396.php:%d
12-
Stack trace:
13-
#0 %s%ebug77396.php(%d): PharData->__construct(%s)
14-
#1 {main}
15-
thrown in %s%ebug77396.php on line %d
14+
--EXPECT--
15+
Phar creation or opening failed

0 commit comments

Comments
 (0)