aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-06-26 16:10:41 +0000
committerRichard M. Stallman1994-06-26 16:10:41 +0000
commitee139ed38ba8d3b1f78c5253cd003b3d62bced3d (patch)
tree4827ba31260d5f80512fc2b8a665eb91c9da4e54
parentd2287ded099c3465669510bcff1d3984c486e677 (diff)
downloademacs-ee139ed38ba8d3b1f78c5253cd003b3d62bced3d.tar.gz
emacs-ee139ed38ba8d3b1f78c5253cd003b3d62bced3d.zip
(jka-compr-partial-uncompress): Handle the case where
LEN reaches to or past the end of the data.
-rw-r--r--lisp/jka-compr.el7
1 files changed, 4 insertions, 3 deletions
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index 0b3b60dc056..3247042eb7e 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -237,9 +237,7 @@ based on the filename itself and `jka-compr-compression-info-list'."
237(defun jka-compr-partial-uncompress (prog message args infile beg len) 237(defun jka-compr-partial-uncompress (prog message args infile beg len)
238 "Call program PROG with ARGS args taking input from INFILE. 238 "Call program PROG with ARGS args taking input from INFILE.
239Fourth and fifth args, BEG and LEN, specify which part of the output 239Fourth and fifth args, BEG and LEN, specify which part of the output
240to discard. All output is discarded unless it comes within LEN chars after 240to keep: LEN chars starting BEG chars from the beginning."
241the BEGth char."
242
243 (let* ((skip (/ beg jka-compr-dd-blocksize)) 241 (let* ((skip (/ beg jka-compr-dd-blocksize))
244 (prefix (- beg (* skip jka-compr-dd-blocksize))) 242 (prefix (- beg (* skip jka-compr-dd-blocksize)))
245 (count (and len (1+ (/ (+ len prefix) jka-compr-dd-blocksize)))) 243 (count (and len (1+ (/ (+ len prefix) jka-compr-dd-blocksize))))
@@ -267,10 +265,13 @@ the BEGth char."
267 265
268 (jka-compr-delete-temp-file err-file)) 266 (jka-compr-delete-temp-file err-file))
269 267
268 ;; Delete the stuff after what we want, if there is any.
270 (and 269 (and
271 len 270 len
271 (< (+ start prefix len) (point))
272 (delete-region (+ start prefix len) (point))) 272 (delete-region (+ start prefix len) (point)))
273 273
274 ;; Delete the stuff before what we want.
274 (delete-region start (+ start prefix)))) 275 (delete-region start (+ start prefix))))
275 276
276 277