unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* image size limit?
@ 2005-10-11 20:32 Chong Yidong
  2005-10-11 21:19 ` Kevin Rodgers
  2005-10-12 16:24 ` Richard M. Stallman
  0 siblings, 2 replies; 24+ messages in thread
From: Chong Yidong @ 2005-10-11 20:32 UTC (permalink / raw)


Can we get this discussion going again?  From FOR-RELEASE:

  Put a max-limit on the size of images, e.g. based on the display
  size.  This is to avoid allocating insane amounts of memory due to
  bogus image size specifications.  Note: rather than clipping images
  that are too big (this may be non-trivial to do correctly in all
  cases -- and thus non-trivial to test), it may be better just to
  avoid displaying such images for emacs 22.

I am not an expert, but from looking through image.c, it seems that
there is only so much we can do to prevent memory over-allocation
problems.  Generally, we have to call an external library to load an
image file, which does its own memory management thing.  By the time
we know the width and height, the external library has already loaded
the file into memory (or signalled an error).

For example, gif_load looks something like this:

  gif = (GifFileType *)fn_DGifOpenFileName (SDATA (file));
  ....
  /* Read entire contents.  */
  rc = fn_DGifSlurp (gif);
  ...
  image_top = gif->SavedImages[ino].ImageDesc.Top;
  ...
  x_create_x_image_and_pixmap (f, width, height, ...);

We have no control over what DGifSlurp does.

One place where we can set a limit is in x_create_x_image_and_pixmap,
where we malloc a pixmap to store the image contents.  The data
supplied to us by the external library is copied into this pixmap.  We
could signal an error if width and height are too large.  However,
this seems like closing the barn door after the horses have left --
the external library will already have allocated a big chunk of
memory.

Thoughts?

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2005-10-20  4:54 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-11 20:32 image size limit? Chong Yidong
2005-10-11 21:19 ` Kevin Rodgers
2005-10-12 16:24 ` Richard M. Stallman
2005-10-12 17:40   ` Romain Francoise
2005-10-13 20:13     ` Richard M. Stallman
2005-10-14 13:02       ` Chong Yidong
2005-10-15 16:13         ` Richard M. Stallman
2005-10-15 18:33           ` Chong Yidong
2005-10-16 17:36             ` Richard M. Stallman
2005-10-16 22:27       ` Chong Yidong
2005-10-17 17:30         ` Richard M. Stallman
2005-10-17 21:56           ` Chong Yidong
2005-10-18  3:39             ` Richard M. Stallman
2005-10-18 14:33               ` Stefan Monnier
2005-10-19  8:35                 ` Kim F. Storm
2005-10-19 12:20                   ` David Kastrup
2005-10-19 12:45                     ` Chong Yidong
2005-10-19 20:17                       ` Richard M. Stallman
2005-10-19 12:51                     ` Kim F. Storm
2005-10-19 20:17                       ` Richard M. Stallman
2005-10-19 21:55                         ` Kim F. Storm
2005-10-19 13:27                 ` Miles Bader
2005-10-20  4:54                   ` Richard M. Stallman
2005-10-19  9:02             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).