[gjs/wip/ptomato/mozjs31prep: 1/3] test: Fix use after free
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31prep: 1/3] test: Fix use after free
- Date: Tue, 18 Oct 2016 19:28:21 +0000 (UTC)
commit 0e9c3ccca99b38c031f64ef8d14c9fbde2ee35ec
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Oct 16 23:05:02 2016 -0700
test: Fix use after free
Noticed this while working on the unit test fixtures, so cleaned it up.
https://bugzilla.gnome.org/show_bug.cgi?id=742249
test/gjs-tests.cpp | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 6bc5901..a2141da 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -127,7 +127,6 @@ gjstest_test_func_gjs_jsapi_util_error_throw(void)
JSObject *global;
JS::Value exc, value;
char *s = NULL;
- int strcmp_result;
_gjs_unit_test_fixture_begin(&fixture);
context = fixture.context;
@@ -150,11 +149,9 @@ gjstest_test_func_gjs_jsapi_util_error_throw(void)
g_assert(value.isString());
gjs_string_to_utf8(context, value, &s);
- g_assert(s != NULL);
- strcmp_result = strcmp(s, "This is an exception 42");
- free(s);
- if (strcmp_result != 0)
- g_error("Exception has wrong message '%s'", s);
+ g_assert_nonnull(s);
+ g_assert_cmpstr(s, ==, "This is an exception 42");
+ JS_free(context, s);
/* keep this around before we clear it */
JS::RootedValue previous(context, exc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]