[PATCH wayland] scanner: Fail on empty enumerations

Hardening rdp.effort at gmail.com
Fri Mar 20 01:43:15 PDT 2015


Le 19/03/2015 09:58, Jonas Ådahl a écrit :
> 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 at gmail.com>

+1

Reviewed-By: David FORT <contact at hardening-consulting.com>

> ---
>  src/scanner.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 1f1e59a..64431a1 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -551,6 +551,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;
>  	}
>  }
> 


-- 
David FORT
website: http://www.hardening-consulting.com/



More information about the wayland-devel mailing list