From 971f8e4ace3d4080340f43574043c31f46db312f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 14 Jul 2022 08:36:21 -0700 Subject: [PATCH] Do not allow nullable `new_id` The usefulness of this is limited, and `libwayland-client` doesn't provide a way to pass a null `new_id` since the id is generated by the library and given to the caller as the return value. Signed-off-by: Ian Douglas Scott --- src/connection.c | 4 ++-- src/scanner.c | 1 - tests/connection-test.c | 3 --- tests/message-test.c | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/connection.c b/src/connection.c index 594f2e93..ceaeac14 100644 --- a/src/connection.c +++ b/src/connection.c @@ -630,7 +630,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode, break; case 'n': object = args[i].o; - if (!arg.nullable && object == NULL) + if (object == NULL) goto err_null; closure->args[i].n = object ? object->id : 0; @@ -799,7 +799,7 @@ wl_connection_demarshal(struct wl_connection *connection, id = *p++; closure->args[i].n = id; - if (id == 0 && !arg.nullable) { + if (id == 0) { wl_log("NULL new ID received on non-nullable " "type, message %s(%s)\n", message->name, message->signature); diff --git a/src/scanner.c b/src/scanner.c index 551d8177..da8adea4 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -414,7 +414,6 @@ is_nullable_type(struct arg *arg) /* Strings and objects are possibly nullable */ case STRING: case OBJECT: - case NEW_ID: return true; default: return false; diff --git a/tests/connection-test.c b/tests/connection-test.c index 592e27ef..9762e0da 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -245,9 +245,6 @@ TEST(connection_marshal) marshal(&data, "n", 12, &object); assert(data.buffer[2] == object.id); - marshal(&data, "?n", 12, NULL); - assert(data.buffer[2] == 0); - array.data = (void *) text; array.size = sizeof text; marshal(&data, "a", 20, &array); diff --git a/tests/message-test.c b/tests/message-test.c index 40293a99..86f387ab 100644 --- a/tests/message-test.c +++ b/tests/message-test.c @@ -63,8 +63,8 @@ TEST(message_count_arrays) { "middle", "iufasonh", NULL }, { "multiple", "aaiufaasonhaa", NULL }, { "leading_version", "2aaiufaasonhaa", NULL }, - { "among_nullables", "iufsa?oa?nah", NULL }, - { "all_mixed", "2aiufas?oa?na", NULL }, + { "among_nullables", "iufsa?oa?sah", NULL }, + { "all_mixed", "2aiufas?oa?sa", NULL }, }; const struct { const struct wl_message *message;