connection: reserve id on incoming new object
authorMathias Fiedler <mathias.fiedler@xse.de>
Wed, 18 Jul 2012 13:53:23 +0000 (15:53 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Sun, 22 Jul 2012 18:09:51 +0000 (14:09 -0400)
If a new object id arrives ensure that there is an empty array entry
created, otherwise we might get out of sync for new ids if object isn't
created by interface implementation.

src/connection.c

index 5946556..f4f881e 100644 (file)
@@ -756,14 +756,14 @@ wl_connection_demarshal(struct wl_connection *connection,
                        closure->args[i] = id;
                        *id = p;
 
-                       object = wl_map_lookup(objects, *p);
-                       if (object != NULL) {
-                               printf("not a new object (%d), "
+                       if (wl_map_reserve_new(objects, *p) < 0) {
+                               printf("not a valid new object id (%d), "
                                       "message %s(%s)\n",
                                       *p, message->name, message->signature);
                                errno = EINVAL;
                                goto err;
                        }
+
                        p++;
                        break;
                case 'a':