diff options
| author | Kenichi Handa | 2012-10-14 17:06:11 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-10-14 17:06:11 +0900 |
| commit | 9fe32d61c5655878f877522ac4bcc251d092f732 (patch) | |
| tree | 584f4c85fd2e44e8e7d597382f177359b737acb1 /src/image.c | |
| parent | f5772b8eaee90d0b50a60bd55d9d28805a2543cb (diff) | |
| parent | 8111f5e6f05228e36496f3bdccad711f569acb9b (diff) | |
| download | emacs-9fe32d61c5655878f877522ac4bcc251d092f732.tar.gz emacs-9fe32d61c5655878f877522ac4bcc251d092f732.zip | |
merge trunk
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/src/image.c b/src/image.c index 9b41cf74993..d52c3a29a27 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2140,12 +2140,11 @@ x_find_image_file (Lisp_Object file) | |||
| 2140 | static unsigned char * | 2140 | static unsigned char * |
| 2141 | slurp_file (char *file, ptrdiff_t *size) | 2141 | slurp_file (char *file, ptrdiff_t *size) |
| 2142 | { | 2142 | { |
| 2143 | FILE *fp = NULL; | 2143 | FILE *fp = fopen (file, "rb"); |
| 2144 | unsigned char *buf = NULL; | 2144 | unsigned char *buf = NULL; |
| 2145 | struct stat st; | 2145 | struct stat st; |
| 2146 | 2146 | ||
| 2147 | if (stat (file, &st) == 0 | 2147 | if (fp && fstat (fileno (fp), &st) == 0 |
| 2148 | && (fp = fopen (file, "rb")) != NULL | ||
| 2149 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) | 2148 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) |
| 2150 | && (buf = xmalloc (st.st_size), | 2149 | && (buf = xmalloc (st.st_size), |
| 2151 | fread (buf, 1, st.st_size, fp) == st.st_size)) | 2150 | fread (buf, 1, st.st_size, fp) == st.st_size)) |
| @@ -5004,45 +5003,6 @@ pbm_scan_number (unsigned char **s, unsigned char *end) | |||
| 5004 | } | 5003 | } |
| 5005 | 5004 | ||
| 5006 | 5005 | ||
| 5007 | #ifdef HAVE_NTGUI | ||
| 5008 | #if 0 /* Unused. ++kfs */ | ||
| 5009 | |||
| 5010 | /* Read FILE into memory. Value is a pointer to a buffer allocated | ||
| 5011 | with xmalloc holding FILE's contents. Value is null if an error | ||
| 5012 | occurred. *SIZE is set to the size of the file. */ | ||
| 5013 | |||
| 5014 | static char * | ||
| 5015 | pbm_read_file (Lisp_Object file, int *size) | ||
| 5016 | { | ||
| 5017 | FILE *fp = NULL; | ||
| 5018 | char *buf = NULL; | ||
| 5019 | struct stat st; | ||
| 5020 | |||
| 5021 | if (stat (SDATA (file), &st) == 0 | ||
| 5022 | && (fp = fopen (SDATA (file), "rb")) != NULL | ||
| 5023 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) | ||
| 5024 | && (buf = xmalloc (st.st_size), | ||
| 5025 | fread (buf, 1, st.st_size, fp) == st.st_size)) | ||
| 5026 | { | ||
| 5027 | *size = st.st_size; | ||
| 5028 | fclose (fp); | ||
| 5029 | } | ||
| 5030 | else | ||
| 5031 | { | ||
| 5032 | if (fp) | ||
| 5033 | fclose (fp); | ||
| 5034 | if (buf) | ||
| 5035 | { | ||
| 5036 | xfree (buf); | ||
| 5037 | buf = NULL; | ||
| 5038 | } | ||
| 5039 | } | ||
| 5040 | |||
| 5041 | return buf; | ||
| 5042 | } | ||
| 5043 | #endif | ||
| 5044 | #endif /* HAVE_NTGUI */ | ||
| 5045 | |||
| 5046 | /* Load PBM image IMG for use on frame F. */ | 5006 | /* Load PBM image IMG for use on frame F. */ |
| 5047 | 5007 | ||
| 5048 | static bool | 5008 | static bool |