bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55938: [PATCH] bindat (strz): Error on null byte if packing variable


From: Stefan Monnier
Subject: bug#55938: [PATCH] bindat (strz): Error on null byte if packing variable-length string
Date: Mon, 13 Jun 2022 09:12:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>    (let* ((v (string-to-unibyte v))
>           (len (length v)))
>      (dotimes (i len)
> +      (if (= (aref v i) 0)
> +          ;; Alternatively we could pretend that this was the end of
> +          ;; the string and stop packing, but then bindat-length would
> +          ;; need to scan the input string looking for a null byte.
> +          (error "Null byte encountered in input strz string"))

I suspect a `string-match` looking for NUL would be faster.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]