From 0583ce741ed16315af591e9e4547a1e3d2c26e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 19 Mar 2015 16:56:23 +0800 Subject: [PATCH] scanner: Fail on empty enumerations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Derek Foreman Reviewed-by: David Fort Reviewed-by: Pekka Paalanen --- src/scanner.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scanner.c b/src/scanner.c index efdc69c6..adc9aa3b 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -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; } }