[seed] [libseed] Fix bug in seed_value_to_string where if an object had an explicitly null toString member



commit 5e7849a059c22653f0262c437b1a594a608ce91f
Author: Robert Carr <racarr gnome org>
Date:   Sat Aug 1 17:52:34 2009 -0400

    [libseed] Fix bug in seed_value_to_string where if an object had an explicitly null toString member (overriding the default object one), it would cause a crash

 libseed/seed-types.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index c1a3bc8..80215bf 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -1949,11 +1949,14 @@ seed_value_to_string (JSContextRef ctx,
 	{
 	  func =
 	    seed_object_get_property (ctx, (JSObjectRef) val, "toString");
-	  str =
-	    JSObjectCallAsFunction (ctx, (JSObjectRef) func,
-				    (JSObjectRef) val, 0, NULL, NULL);
+	  if (!JSValueIsNull (ctx, func) &&
+	      JSValueIsObject (ctx, func) &&
+	      JSObjectIsFunction (ctx, (JSObjectRef) func))
+	    str =
+	      JSObjectCallAsFunction (ctx, (JSObjectRef) func,
+				      (JSObjectRef) val, 0, NULL, NULL);
 	}
-
+      
       jsstr = JSValueToStringCopy (ctx, val, NULL);
       length = JSStringGetMaximumUTF8CStringSize (jsstr);
       if (length > 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]