[vala/staging] tests: Fix try_parse() tests to not compare to already free'd memory
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Fix try_parse() tests to not compare to already free'd memory
- Date: Fri, 4 Jan 2019 19:04:56 +0000 (UTC)
commit ba7baed0ad5d30bbacf830daca6c5e843fecdaef
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Jan 4 20:02:18 2019 +0100
tests: Fix try_parse() tests to not compare to already free'd memory
Found with valgrind
tests/basic-types/integers.vala | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/tests/basic-types/integers.vala b/tests/basic-types/integers.vala
index 90618351d..1500ab266 100644
--- a/tests/basic-types/integers.vala
+++ b/tests/basic-types/integers.vala
@@ -91,17 +91,21 @@ void test_int () {
assert (s == "42");
unowned string unparsed;
+ s = "%lim".printf (long.MIN);
long l;
- long.try_parse ("%lim".printf (long.MIN), out l, out unparsed);
+ long.try_parse (s, out l, out unparsed);
assert (l == long.MIN);
assert (unparsed == "m");
- assert (!long.try_parse ("%lum".printf (ulong.MAX), out l));
+ s = "%lum".printf (ulong.MAX);
+ assert (!long.try_parse (s, out l));
+ s = "%lum".printf (ulong.MAX);
ulong ul;
- ulong.try_parse ("%lum".printf (ulong.MAX), out ul, out unparsed);
+ ulong.try_parse (s, out ul, out unparsed);
assert (ul == ulong.MAX);
assert (unparsed == "m");
- assert (!ulong.try_parse ("%lim".printf (long.MIN), out ul));
+ s = "%lim".printf (long.MIN);
+ assert (!ulong.try_parse (s, out ul));
int64 i64;
int64.try_parse ("-4711inch", out i64, out unparsed);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]