[gjs] gi: assert we don't access argv out of bounds
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] gi: assert we don't access argv out of bounds
- Date: Tue, 2 Mar 2010 19:05:19 +0000 (UTC)
commit 29bc4463d03388c5f420fdbb8715c1e265e32786
Author: Tommi Komulainen <tko litl com>
Date: Mon Mar 1 19:03:07 2010 +0000
gi: assert we don't access argv out of bounds
Helps avoid bugs that might otherwise silently creep in.
https://bugzilla.gnome.org/show_bug.cgi?id=611603
gi/function.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index 250f526..8b4f02f 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -606,10 +606,14 @@ gjs_invoke_c_function(JSContext *context,
if (g_slist_find(callback_arg_indices, GUINT_TO_POINTER((guint)i)) != NULL) {
g_assert(type_tag == GI_TYPE_TAG_VOID);
convert_argument = FALSE;
+
+ g_assert_cmpuint(argv_pos, <, argc);
in_value->v_pointer = (gpointer)argv[argv_pos];
} else if (type_tag == GI_TYPE_TAG_VOID) {
/* FIXME: notify/throw saying the callback annotation is wrong */
convert_argument = FALSE;
+
+ g_assert_cmpuint(argv_pos, <, argc);
in_value->v_pointer = (gpointer)argv[argv_pos];
} else if (type_tag == GI_TYPE_TAG_INTERFACE) {
GIBaseInfo* interface_info;
@@ -637,12 +641,14 @@ gjs_invoke_c_function(JSContext *context,
g_base_info_unref(interface_info);
}
- if (convert_argument)
+ if (convert_argument) {
+ g_assert_cmpuint(argv_pos, <, argc);
if (!gjs_value_to_arg(context, argv[argv_pos], &arg_info,
in_value)) {
failed = TRUE;
break;
}
+ }
if (!failed && direction == GI_DIRECTION_INOUT) {
g_assert_cmpuint(in_args_pos, <, in_args_len);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]