diff options
author | Richard Hansen <rhansen@rhansen.org> | 2022-05-29 18:09:08 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-06-01 22:24:05 -0400 |
commit | 5255fa452f338c2ae97fa1ade70b396513bc6e9b (patch) | |
tree | 76a9cd2053a15459e463bfffe0370b7b996f092d /lisp/emacs-lisp/bindat.el | |
parent | 30ec4a7347b2944818c6fc469ae871374ce7caa4 (diff) | |
download | emacs-5255fa452f338c2ae97fa1ade70b396513bc6e9b.tar.gz emacs-5255fa452f338c2ae97fa1ade70b396513bc6e9b.tar.bz2 emacs-5255fa452f338c2ae97fa1ade70b396513bc6e9b.zip |
bindat (strz): Fix wrong-type-argument error when unpacking
* lisp/emacs-lisp/bindat.el (strz): Fix (wrong-type-argument
number-or-marker-p nil) error when unpacking a strz with
unspecified (variable) length.
* test/lisp/emacs-lisp/bindat-tests.el (strz): Mark test as passing.
Diffstat (limited to 'lisp/emacs-lisp/bindat.el')
-rw-r--r-- | lisp/emacs-lisp/bindat.el | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el index e597dd62479..0725b677cff 100644 --- a/lisp/emacs-lisp/bindat.el +++ b/lisp/emacs-lisp/bindat.el @@ -165,12 +165,12 @@ (if (stringp s) s (apply #'unibyte-string s)))) -(defun bindat--unpack-strz (len) +(defun bindat--unpack-strz (&optional len) (let ((i 0) s) (while (and (if len (< i len) t) (/= (aref bindat-raw (+ bindat-idx i)) 0)) (setq i (1+ i))) (setq s (substring bindat-raw bindat-idx (+ bindat-idx i))) - (setq bindat-idx (+ bindat-idx len)) + (setq bindat-idx (+ bindat-idx (or len (1+ i)))) (if (stringp s) s (apply #'unibyte-string s)))) |