(gnus-html-image-fetched): Protect against the data not arriving.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 19 Sep 2010 19:06:18 +0000 (21:06 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 19 Sep 2010 19:06:18 +0000 (21:06 +0200)
lisp/ChangeLog
lisp/gnus-html.el

index 43c174d..3325811 100644 (file)
@@ -1,5 +1,8 @@
 2010-09-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * gnus-html.el (gnus-html-image-fetched): Protect against the data not
+       arriving.
+
        * gnus-start.el (gnus-ignored-newsgroups): Remove [] from the list of
        bogus characters.  This allows selecting certain Gmail groups.
 
index 7ac3dd4..819a6d6 100644 (file)
@@ -336,23 +336,23 @@ fit these criteria."
 (defun gnus-html-image-fetched (status buffer image)
   (let ((file (gnus-html-image-id (car image))))
     ;; Search the start of the image data
-    (search-forward "\n\n")
-    ;; Write region (image data) silently
-    (write-region (point) (point-max) file nil 1)
-    (kill-buffer)
-    (when (and (buffer-live-p buffer)
-               ;; If the `image' has no marker, do not replace anything
-               (cadr image)
-               ;; If the position of the marker is 1, then that
-               ;; means that the text it was in has been deleted;
-               ;; i.e., that the user has selected a different
-               ;; article before the image arrived.
-               (not (= (marker-position (cadr image)) (point-min))))
-      (with-current-buffer buffer
-        (let ((inhibit-read-only t)
-              (string (buffer-substring (cadr image) (caddr image))))
-          (delete-region (cadr image) (caddr image))
-          (gnus-html-put-image file (cadr image) (car image) string))))))
+    (when (search-forward "\n\n" nil t)
+      ;; Write region (image data) silently
+      (write-region (point) (point-max) file nil 1)
+      (kill-buffer)
+      (when (and (buffer-live-p buffer)
+                ;; If the `image' has no marker, do not replace anything
+                (cadr image)
+                ;; If the position of the marker is 1, then that
+                ;; means that the text it was in has been deleted;
+                ;; i.e., that the user has selected a different
+                ;; article before the image arrived.
+                (not (= (marker-position (cadr image)) (point-min))))
+       (with-current-buffer buffer
+         (let ((inhibit-read-only t)
+               (string (buffer-substring (cadr image) (caddr image))))
+           (delete-region (cadr image) (caddr image))
+           (gnus-html-put-image file (cadr image) (car image) string)))))))
 
 (defun gnus-html-put-image (file point string &optional url alt-text)
   (when (gnus-graphic-display-p)