From: Rico Tzschichholz Date: Tue, 11 Aug 2020 08:03:14 +0000 (+0200) Subject: tests: Don't rely on undefined use-after-free behaviour of glibc X-Git-Tag: 0.49.90~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b34161f2b8571ecfa40ddbfb84bb6dc1e6245a25;p=thirdparty%2Fvala.git tests: Don't rely on undefined use-after-free behaviour of glibc Makes this check work with musl >= 1.2.1 https://bugzilla.gnome.org/show_bug.cgi?id=736774 --- diff --git a/tests/control-flow/bug736774-1.vala b/tests/control-flow/bug736774-1.vala index 1fd70a40e..db6c66fac 100644 --- a/tests/control-flow/bug736774-1.vala +++ b/tests/control-flow/bug736774-1.vala @@ -1,8 +1,8 @@ -bool success = false; +int success = 0; class Foo : Object { ~Foo() { - success = true; + success++; } } @@ -19,5 +19,5 @@ void main() { } catch { } - assert (success); + assert (success == 1); } diff --git a/tests/control-flow/bug736774-2.vala b/tests/control-flow/bug736774-2.vala index f54ce5cbd..a7d983f96 100644 --- a/tests/control-flow/bug736774-2.vala +++ b/tests/control-flow/bug736774-2.vala @@ -1,8 +1,20 @@ -string* keep; +int success = 0; -string may_fail () throws GLib.Error { - string result = "test"; - keep = result; +[Compact] +[Immutable] +[CCode (free_function = "vstring_destroy")] +public class vstring : string { + public vstring (string s); + + [DestroysInstance] + public void destroy () { + free (this); + success++; + } +} + +vstring may_fail () throws GLib.Error { + vstring result = (vstring) "test".dup (); return (owned) result; } @@ -12,5 +24,5 @@ void main () { } catch { } - assert (keep != "test"); + assert (success == 1); }