[Swfdec] 2 commits - libswfdec/swfdec_as_array.c libswfdec/swfdec_asbroadcaster.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_string.c libswfdec/swfdec_color_as.c libswfdec/swfdec_initialize.as

Pekka Lampila medar at kemper.freedesktop.org
Wed Nov 14 02:45:05 PST 2007


 libswfdec/swfdec_as_array.c      |   36 ++++++++++++++++++++++++++++++++++++
 libswfdec/swfdec_as_object.c     |   12 +++++++++++-
 libswfdec/swfdec_as_string.c     |    8 +++++++-
 libswfdec/swfdec_asbroadcaster.c |    3 +++
 libswfdec/swfdec_color_as.c      |   14 ++++++++++++--
 libswfdec/swfdec_initialize.as   |    1 -
 6 files changed, 69 insertions(+), 5 deletions(-)

New commits:
commit e83bc46f533bc7c1c3155f46dc39634818a92f18
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Wed Nov 14 12:44:52 2007 +0200

    Fix some crashes/asserts when this is null

diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
index 4c30399..3c6cde5 100644
--- a/libswfdec/swfdec_as_array.c
+++ b/libswfdec/swfdec_as_array.c
@@ -589,6 +589,9 @@ swfdec_as_array_join (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   const char *var, *str, *sep;
   SwfdecAsValue val;
 
+  if (object == NULL)
+    return;
+
   if (argc > 0) {
     sep = swfdec_as_value_to_string (cx, &argv[0]);
   } else {
@@ -623,6 +626,9 @@ void
 swfdec_as_array_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
+  if (object == NULL)
+    return;
+
   swfdec_as_array_join (cx, object, 0, NULL, ret);
 }
 
@@ -631,6 +637,9 @@ void
 swfdec_as_array_do_push (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
+  if (object == NULL)
+    return;
+
   // if 0 args, just return the length
   // manually set the length here to make the function work on non-Arrays
   if (argc > 0) {
@@ -650,6 +659,9 @@ swfdec_as_array_do_pop (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   gint32 length;
   const char *var;
 
+  if (object == NULL)
+    return;
+
   // we allow negative indexes here, but not 0
   length = swfdec_as_array_length_as_integer (object);
   if (length == 0)
@@ -674,6 +686,9 @@ swfdec_as_array_do_unshift (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   gint32 length;
 
+  if (object == NULL)
+    return;
+
   if (argc) {
     // don't allow negative length
     length = swfdec_as_array_length (object);
@@ -695,6 +710,9 @@ swfdec_as_array_do_shift (SwfdecAsContext *cx, SwfdecAsObject *object,
   gint32 length;
   const char *var;
 
+  if (object == NULL)
+    return;
+
   // don't allow negative length
   length = swfdec_as_array_length (object);
   if (length <= 0)
@@ -743,6 +761,9 @@ swfdec_as_array_reverse (SwfdecAsContext *cx, SwfdecAsObject *object,
 {
   gint32 length;
 
+  if (object == NULL)
+    return;
+
   length = swfdec_as_array_length (object);
   swfdec_as_object_foreach_rename (object, swfdec_as_array_foreach_reverse,
       &length);
@@ -760,6 +781,9 @@ swfdec_as_array_concat (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   SwfdecAsArray *array_new;
   const char *var;
 
+  if (object == NULL)
+    return;
+
   object_new = swfdec_as_array_new (cx);
   if (object_new == NULL)
     return;
@@ -794,6 +818,9 @@ swfdec_as_array_slice (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   SwfdecAsObject *object_new;
   SwfdecAsArray *array_new;
 
+  if (object == NULL)
+    return;
+
   length = swfdec_as_array_length (object);
 
   if (argc > 0) {
@@ -834,6 +861,9 @@ swfdec_as_array_splice (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   SwfdecAsObject *object_new;
   SwfdecAsArray *array_new;
 
+  if (object == NULL)
+    return;
+
   length = swfdec_as_array_length (object);
 
   if (argc > 0) {
@@ -1260,6 +1290,9 @@ swfdec_as_array_sort (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   gint32 options;
   SwfdecAsFunction *custom_compare_func;
 
+  if (object == NULL)
+    return;
+
   pos = 0;
   if (argc > 0 && !SWFDEC_AS_VALUE_IS_NUMBER (&argv[0])) {
     SwfdecAsFunction *fun;
@@ -1290,6 +1323,9 @@ swfdec_as_array_sortOn (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
   const char **fields;
   gint32 options;
 
+  if (object == NULL)
+    return;
+
   if (argc < 1)
     return;
 
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index bb4adcc..5cc446c 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -1422,6 +1422,9 @@ swfdec_as_object_hasOwnProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
 
   SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
 
+  if (object == NULL)
+    return;
+
   // return false even if no params
   if (argc < 1)
     return;
@@ -1449,6 +1452,9 @@ swfdec_as_object_isPropertyEnumerable (SwfdecAsContext *cx,
 
   SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
 
+  if (object == NULL)
+    return;
+
   // return false even if no params
   if (argc < 1)
     return;
@@ -1546,6 +1552,9 @@ swfdec_as_object_unwatch (SwfdecAsContext *cx, SwfdecAsObject *object,
   SwfdecAsVariable *var;
   const char *name;
 
+  if (object == NULL)
+    return;
+
   SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
 
   if (argc < 1)
@@ -1574,7 +1583,8 @@ void
 swfdec_as_object_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
-  SWFDEC_AS_VALUE_SET_OBJECT (retval, object);
+  if (object != NULL)
+    SWFDEC_AS_VALUE_SET_OBJECT (retval, object);
 }
 
 SWFDEC_AS_NATIVE (101, 4, swfdec_as_object_toString)
diff --git a/libswfdec/swfdec_as_string.c b/libswfdec/swfdec_as_string.c
index 59515d9..d15c81b 100644
--- a/libswfdec/swfdec_as_string.c
+++ b/libswfdec/swfdec_as_string.c
@@ -75,7 +75,13 @@ swfdec_as_string_object_to_string (SwfdecAsContext *context,
 {
   SwfdecAsValue val;
 
-  g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+  g_return_val_if_fail (object == NULL || SWFDEC_IS_AS_OBJECT (object),
+      SWFDEC_AS_STR_EMPTY);
+
+  if (object == NULL) {
+    SWFDEC_FIXME ("What to do when this is null in string functions");
+    return SWFDEC_AS_STR_EMPTY;
+  }
 
   SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
 
diff --git a/libswfdec/swfdec_asbroadcaster.c b/libswfdec/swfdec_asbroadcaster.c
index 05897e8..7d26d64 100644
--- a/libswfdec/swfdec_asbroadcaster.c
+++ b/libswfdec/swfdec_asbroadcaster.c
@@ -39,6 +39,9 @@ broadcastMessage (SwfdecAsContext *cx, SwfdecAsObject *object,
   const char *name;
   GSList *list = NULL, *walk;
 
+  if (object == NULL)
+    return;
+
   if (argc < 1)
     return;
   name = swfdec_as_value_to_string (cx, &argv[0]);
diff --git a/libswfdec/swfdec_color_as.c b/libswfdec/swfdec_color_as.c
index b09354c..6bd1878 100644
--- a/libswfdec/swfdec_color_as.c
+++ b/libswfdec/swfdec_color_as.c
@@ -54,7 +54,12 @@ swfdec_movie_color_getRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
 {
   int result;
-  SwfdecMovie *movie = swfdec_movie_color_get_movie (obj);
+  SwfdecMovie *movie;
+
+  if (obj == NULL)
+    return;
+
+  movie = swfdec_movie_color_get_movie (obj);
   
   if (movie == NULL)
     return;
@@ -80,7 +85,12 @@ swfdec_movie_color_getTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   SwfdecAsObject *ret;
-  SwfdecMovie *movie = swfdec_movie_color_get_movie (obj);
+  SwfdecMovie *movie;
+
+  if (obj == NULL)
+    return;
+
+  movie = swfdec_movie_color_get_movie (obj);
   
   if (movie == NULL)
     return;
commit da41d4aaa334d1260cc9891ba01bdc3d10350b95
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Wed Nov 14 12:27:24 2007 +0200

    lal

diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
index dee0157..d02ff9a 100644
--- a/libswfdec/swfdec_initialize.as
+++ b/libswfdec/swfdec_initialize.as
@@ -28,7 +28,6 @@ ASSetNativeAccessor = ASnative (4, 1);
 
 Object.registerClass = ASnative(101, 8);
 ASSetPropFlags (Object, null, 7);
-lal
 
 /*** Error ***/
 


More information about the Swfdec mailing list