diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2011-10-24 16:04:09 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-10-24 16:04:09 -0400 |
commit | d63884b0c701a24f3bfdded036c5d5b6b2b6bd0d (patch) | |
tree | 36ff190b36888cc966211beaf17b8c12e3f5999d /src | |
parent | 1ac009473bab32a304beb4f115fbae2514824a06 (diff) |
scanner: Catch more invalid attribute combinations for arg
Spotted by Jakob Bornecrantz.
Diffstat (limited to 'src')
-rw-r--r-- | src/scanner.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/scanner.c b/src/scanner.c index 4cce808..c03597c 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -230,19 +230,27 @@ start_element(void *data, const char *element_name, const char **atts) else if (strcmp(type, "fd") == 0) arg->type = FD; else if (strcmp(type, "new_id") == 0) { - if (interface_name == NULL) - fail(ctx, "no interface name given"); arg->type = NEW_ID; arg->interface_name = strdup(interface_name); } else if (strcmp(type, "object") == 0) { - if (interface_name == NULL) - fail(ctx, "no interface name given"); arg->type = OBJECT; arg->interface_name = strdup(interface_name); } else { fail(ctx, "unknown type"); } + switch (arg->type) { + case NEW_ID: + case OBJECT: + if (interface_name == NULL) + fail(ctx, "no interface name given"); + break; + default: + if (interface_name != NULL) + fail(ctx, "interface no allowed"); + break; + } + wl_list_insert(ctx->message->arg_list.prev, &arg->link); ctx->message->arg_count++; } else if (strcmp(element_name, "enum") == 0) { |