diff --git a/NEWS b/NEWS
index b655a47a6f15..bb5f6b75b07b 100644
--- a/NEWS
+++ b/NEWS
@@ -117,6 +117,8 @@ PHP NEWS
(Kévin Dunglas)
. Fixed bug GH-24743 (var_export() ignores exceptions from lazy object
initialization). (lazerg)
+ . Fixed memory leak in get_meta_tags() when a tag opens while an attribute
+ value is expected. (Jorg Sowa)
- Streams:
. Fixed bug GH-22063 (Stream filter chain UAF on self-removal during
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 412af159f19e..eab4aa7f4b74 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -348,13 +348,10 @@ PHP_FUNCTION(get_meta_tags)
} else {
add_assoc_string(return_value, name, "");
}
-
- efree(name);
- if (value) efree(value);
- } else if (have_content) {
- efree(value);
}
+ if (name) efree(name);
+ if (value) efree(value);
name = value = NULL;
/* Reset all of our flags */
diff --git a/ext/standard/tests/strings/get_meta_tags_open_tag_leak.phpt b/ext/standard/tests/strings/get_meta_tags_open_tag_leak.phpt
new file mode 100644
index 000000000000..01f8e4253670
--- /dev/null
+++ b/ext/standard/tests/strings/get_meta_tags_open_tag_leak.phpt
@@ -0,0 +1,25 @@
+--TEST--
+get_meta_tags() does not leak when a tag opens while an attribute value is expected
+--FILE--
+
+
+
+HTML);
+
+var_dump(get_meta_tags($filename));
+
+?>
+--CLEAN--
+
+--EXPECT--
+array(1) {
+ ["baz"]=>
+ string(3) "qux"
+}