scanner: Fail on empty enumerations

Without this patch, the scanner would generate invalid C which wouldn't
compile anyway, so lets be nice and fail earlier and point out where the
error is.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Jonas Ådahl 2015-03-19 16:56:23 +08:00
parent 313b26f415
commit 0583ce741e

View file

@ -552,6 +552,10 @@ end_element(void *data, const XML_Char *name)
strcmp(name, "event") == 0) {
ctx->message = NULL;
} else if (strcmp(name, "enum") == 0) {
if (wl_list_empty(&ctx->enumeration->entry_list)) {
fail(&ctx->loc, "enumeration %s was empty",
ctx->enumeration->name);
}
ctx->enumeration = NULL;
}
}