File Handling
***********************************************************************/
-static unsigned char *slurp_file (char *, int *);
-
-
/* Find image file FILE. Look in data-directory/images, then
x-bitmap-file-path. Value is the encoded full name of the file
found, or nil if not found. */
occurred. *SIZE is set to the size of the file. */
static unsigned char *
-slurp_file (char *file, int *size)
+slurp_file (char *file, ptrdiff_t *size)
{
FILE *fp = NULL;
unsigned char *buf = NULL;
if (stat (file, &st) == 0
&& (fp = fopen (file, "rb")) != NULL
+ && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
&& (buf = (unsigned char *) xmalloc (st.st_size),
fread (buf, 1, st.st_size, fp) == st.st_size))
{
{
Lisp_Object file;
unsigned char *contents;
- int size;
+ ptrdiff_t size;
file = x_find_image_file (file_name);
if (!STRINGP (file))
{
Lisp_Object file;
unsigned char *contents;
- int size;
+ ptrdiff_t size;
file = x_find_image_file (file_name);
if (!STRINGP (file))
if (stat (SDATA (file), &st) == 0
&& (fp = fopen (SDATA (file), "rb")) != NULL
+ && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
&& (buf = (char *) xmalloc (st.st_size),
fread (buf, 1, st.st_size, fp) == st.st_size))
{
enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type;
unsigned char *contents = NULL;
unsigned char *end, *p;
- int size;
+ ptrdiff_t size;
specified_file = image_spec_value (img->spec, QCfile, NULL);
static int svg_load (struct frame *f, struct image *img);
static int svg_load_image (struct frame *, struct image *,
- unsigned char *, unsigned int);
+ unsigned char *, ptrdiff_t);
/* The symbol `svg' identifying images of this type. */
{
Lisp_Object file;
unsigned char *contents;
- int size;
+ ptrdiff_t size;
file = x_find_image_file (file_name);
if (!STRINGP (file))
svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */
struct image *img, /* Pointer to emacs image structure. */
unsigned char *contents, /* String containing the SVG XML data to be parsed. */
- unsigned int size) /* Size of data in bytes. */
+ ptrdiff_t size) /* Size of data in bytes. */
{
RsvgHandle *rsvg_handle;
RsvgDimensionData dimension_data;