[seed] Bugfix: Made Seed.argv check for invalid array parameter
- From: Alan Knowles <alank src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seed] Bugfix: Made Seed.argv check for invalid array parameter
- Date: Wed, 9 Dec 2015 03:01:20 +0000 (UTC)
commit 8012eea197d4366bd7ec72cc57aaf0db897509ec
Author: Peter Rustler <peter rustler basyskom com>
Date: Mon Dec 7 16:52:41 2015 +0000
Bugfix: Made Seed.argv check for invalid array parameter
Seed.argv will drop a segfault when you access the array out of
range.
This patch add checking for valid value of array index.
https://bugzilla.gnome.org/show_bug.cgi?id=759172
libseed/seed-builtins.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/libseed/seed-builtins.c b/libseed/seed-builtins.c
index b5b14fc..3988a3d 100644
--- a/libseed/seed-builtins.c
+++ b/libseed/seed-builtins.c
@@ -469,7 +469,7 @@ seed_argv_get_property (JSContextRef ctx,
SeedArgvPrivates *priv;
gchar *cproperty_name;
gsize length;
- guint index;
+ gint index;
priv = JSObjectGetPrivate (object);
if (!priv->argc)
@@ -483,7 +483,14 @@ seed_argv_get_property (JSContextRef ctx,
return seed_value_from_int (ctx, priv->argc, exception);
}
index = atoi (cproperty_name);
- return seed_value_from_string (ctx, priv->argv[index], exception);
+ if (index >= 0 && index < priv->argc) {
+ return seed_value_from_string (ctx, priv->argv[index], exception);
+ } else {
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "ArgumentCount "
+ "%d, got %d", priv->argc, index);
+ return JSValueMakeNull (ctx);
+ }
}
JSClassDefinition seed_argv_def = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]