Commit f8d682fa705 for php.net

commit f8d682fa7056b5d7eac837a077502e8f98864b5e
Author: Gina Peter Banyard <girgias@php.net>
Date:   Fri Jun 26 10:31:03 2026 +0100

    ext/com: add tests for sa_proxy variant error cases

diff --git a/ext/com_dotnet/tests/bug77177.phpt b/ext/com_dotnet/tests/bug77177.phpt
index 3395f4ed810..cba12980ad9 100644
--- a/ext/com_dotnet/tests/bug77177.phpt
+++ b/ext/com_dotnet/tests/bug77177.phpt
@@ -2,16 +2,11 @@
 Bug #77177 (Serializing or unserializing COM objects crashes)
 --EXTENSIONS--
 com_dotnet
---SKIPIF--
-<?php
-if (!class_exists("dotnet")) die("skip mscoree not available");
-?>
 --FILE--
 <?php
 $com = new COM("WScript.Shell");
-$dotnet = new DOTNET("mscorlib", "System.Collections.Stack");
 $variant = new VARIANT;
-foreach ([$com, $dotnet, $variant] as $object) {
+foreach ([$com, $variant] as $object) {
     try {
         serialize($object);
     } catch (Exception $ex) {
@@ -19,7 +14,7 @@
     }
 }

-$strings = ['C:3:"com":0:{}', 'C:6:"dotnet":0:{}', 'C:7:"variant":0:{}'];
+$strings = ['C:3:"com":0:{}', 'C:7:"variant":0:{}'];
 foreach ($strings as $string) {
     try {
         unserialize($string);
@@ -28,7 +23,7 @@
     }
 }

-$strings = ['O:3:"com":0:{}', 'O:6:"dotnet":0:{}', 'O:7:"variant":0:{}'];
+$strings = ['O:3:"com":0:{}', 'O:7:"variant":0:{}'];
 foreach ($strings as $string) {
     try {
         unserialize($string);
@@ -37,13 +32,10 @@
     }
 }
 ?>
---EXPECTF--
+--EXPECT--
 Exception: Serialization of 'com' is not allowed
-Exception: Serialization of 'dotnet' is not allowed
 Exception: Serialization of 'variant' is not allowed
 Exception: Unserialization of 'com' is not allowed
-Exception: Unserialization of 'dotnet' is not allowed
 Exception: Unserialization of 'variant' is not allowed
 Exception: Unserialization of 'com' is not allowed
-Exception: Unserialization of 'dotnet' is not allowed
 Exception: Unserialization of 'variant' is not allowed
diff --git a/ext/com_dotnet/tests/bug77177_dotnet.phpt b/ext/com_dotnet/tests/bug77177_dotnet.phpt
new file mode 100644
index 00000000000..d80c180ae77
--- /dev/null
+++ b/ext/com_dotnet/tests/bug77177_dotnet.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #77177 (Serializing or unserializing COM objects crashes, dotnet class)
+--EXTENSIONS--
+com_dotnet
+--SKIPIF--
+<?php
+if (!class_exists("dotnet")) die("skip mscoree not available");
+?>
+--FILE--
+<?php
+$dotnet = new DOTNET("mscorlib", "System.Collections.Stack");
+try {
+    serialize($dotnet);
+} catch (Exception $ex) {
+    echo "Exception: {$ex->getMessage()}\n";
+}
+
+try {
+    unserialize('C:6:"dotnet":0:{}');
+} catch (Exception $ex) {
+    echo "Exception: {$ex->getMessage()}\n";
+}
+
+try {
+    unserialize('O:6:"dotnet":0:{}');
+} catch (Exception $ex) {
+    echo "Exception: {$ex->getMessage()}\n";
+}
+?>
+--EXPECT--
+Exception: Serialization of 'dotnet' is not allowed
+Exception: Unserialization of 'dotnet' is not allowed
+Exception: Unserialization of 'dotnet' is not allowed
diff --git a/ext/com_dotnet/tests/sa_proxy_errors.phpt b/ext/com_dotnet/tests/sa_proxy_errors.phpt
new file mode 100644
index 00000000000..99acb0c0152
--- /dev/null
+++ b/ext/com_dotnet/tests/sa_proxy_errors.phpt
@@ -0,0 +1,60 @@
+--TEST--
+com_safearray_proxy errors
+--EXTENSIONS--
+com_dotnet
+--FILE--
+<?php
+
+$binding_string = ['aaa','bbb','ccc'];
+$v = new VARIANT( $binding_string, VT_ARRAY );
+var_dump($v);
+
+try {
+    var_dump(isset($v->hello));
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    var_dump($v->hello);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    $v->hello = 'blah';
+    var_dump($v);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    unset($v->hello);
+    var_dump($v);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    $c = clone $v;
+    var_dump($c);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    $s = serialize($v);
+    var_dump($s);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+object(variant)#1 (0) {
+}
+bool(false)
+com_exception: this variant has no properties
+com_exception: this variant has no properties
+Error: Cannot delete properties from a COM object
+Error: Trying to clone an uncloneable object of class variant
+Exception: Serialization of 'variant' is not allowed
diff --git a/ext/com_dotnet/tests/variant_no_clone.phpt b/ext/com_dotnet/tests/variant_no_clone.phpt
index edb0b3996e7..93d49235ed4 100644
--- a/ext/com_dotnet/tests/variant_no_clone.phpt
+++ b/ext/com_dotnet/tests/variant_no_clone.phpt
@@ -2,7 +2,6 @@
 Prevent cloning of Variant types as it's broken
 --EXTENSIONS--
 com_dotnet
-
 --FILE--
 <?php