From e504d1e850a544d6d139a51beee7ad5c2155c079 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 28 May 2022 23:53:51 -0400 Subject: [PATCH 3/7] ; bindat (strz): Consistent length type check The strz length computation uses `numberp' to switch between fixed-length and variable-length modes, so packing should too. --- lisp/emacs-lisp/bindat.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el index f66458296a..d64be721b2 100644 --- a/lisp/emacs-lisp/bindat.el +++ b/lisp/emacs-lisp/bindat.el @@ -692,13 +692,13 @@ bindat--type `(1+ (length ,val))))) (`(pack . ,args) (macroexp-let2 nil len len - `(if ,len - ;; Same as non-zero terminated strings since we don't actually add - ;; the terminating zero anyway (because we rely on the fact that - ;; `bindat-raw' was presumably initialized with all-zeroes before - ;; we started). - (bindat--pack-str ,len . ,args) - (bindat--pack-strz . ,args)))))) + (if (numberp len) + ;; Same as non-zero terminated strings since we don't actually add + ;; the terminating zero anyway (because we rely on the fact that + ;; `bindat-raw' was presumably initialized with all-zeroes before + ;; we started). + `(bindat--pack-str ,len . ,args) + `(bindat--pack-strz . ,args)))))) (cl-defmethod bindat--type (op (_ (eql 'bits)) len) (bindat--pcase op -- 2.36.1