fix leak with strings!
authorMichael Wallner <mike@php.net>
Wed, 21 Oct 2015 10:06:08 +0000 (12:06 +0200)
committerMichael Wallner <mike@php.net>
Wed, 21 Oct 2015 10:06:08 +0000 (12:06 +0200)
src/module.c
tests/idn/idn003.phpt [new file with mode: 0644]
tests/idn/idn004.phpt [new file with mode: 0644]

index dba74c595852c7260d9e1b91a76f7b630a812022..4e7f4ce61aa59ff0b8c2628055e38092de62abd2 100644 (file)
@@ -289,6 +289,18 @@ void psi_do_clean(impl *impl)
 {
        size_t i;
 
+       for (i = 0; i < impl->func->args->count; ++i ) {
+               impl_arg *iarg = impl->func->args->args[i];
+
+               switch (iarg->type->type) {
+               case PSI_T_STRING:
+                       if (iarg->val.str) {
+                               zend_string_release(iarg->val.str);
+                       }
+                       break;
+               }
+       }
+
        for (i = 0; i < impl->decl->args->count; ++i) {
                decl_arg *darg = impl->decl->args->args[i];
 
diff --git a/tests/idn/idn003.phpt b/tests/idn/idn003.phpt
new file mode 100644 (file)
index 0000000..8befdc9
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+libidn
+--INI--
+psi.directory={PWD}
+--SKIPIF--
+<?php
+extension_loaded("psi") or die("skip - need ext/psi");
+?>
+--FILE--
+===TEST===
+<?php 
+
+$result = "buecher.de";
+$rc = idn\utf8_to_ascii("bücher.de", $result, IDNA_USE_STD3_ASCII_RULES);
+printf("%s\n", $result);
+printf("%s\n", idn\strerror($rc));
+
+?>
+===DONE===
+--EXPECT--
+===TEST===
+xn--bcher-kva.de
+Success
+===DONE===
\ No newline at end of file
diff --git a/tests/idn/idn004.phpt b/tests/idn/idn004.phpt
new file mode 100644 (file)
index 0000000..d70f307
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+libidn
+--INI--
+psi.directory={PWD}
+--SKIPIF--
+<?php
+extension_loaded("psi") or die("skip - need ext/psi");
+?>
+--FILE--
+===TEST===
+<?php 
+
+$result = "buecher.de";
+$rc = idn\utf8_to_ascii("bücher.de", $result, IDNA_USE_STD3_ASCII_RULES);
+printf("%s\n", $result);
+printf("%s\n", idn\strerror($rc));
+
+$rc = idn\utf8_to_ascii("bücher2.de", $result, IDNA_USE_STD3_ASCII_RULES);
+printf("%s\n", $result);
+printf("%s\n", idn\strerror($rc));
+
+?>
+===DONE===
+--EXPECT--
+===TEST===
+xn--bcher-kva.de
+Success
+xn--bcher2-3ya.de
+Success
+===DONE===
\ No newline at end of file