aboutsummaryrefslogtreecommitdiffstats
path: root/code/renderer
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-02-14 11:13:42 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-02-14 11:13:42 +0000
commitc529793fdb60a4b58e6914c4aa0e58e34f688f56 (patch)
tree48dddcfc3e958a96f407a8fe13df8f775e619533 /code/renderer
parent0365c92dcb7fbaf7d98e28883d37453d5fb96670 (diff)
downloadioquake3-aero-c529793fdb60a4b58e6914c4aa0e58e34f688f56.tar.gz
ioquake3-aero-c529793fdb60a4b58e6914c4aa0e58e34f688f56.zip
don't read more memory than available in jpg decode
git-svn-id: svn://svn.icculus.org/quake3/trunk@1259 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/renderer')
-rw-r--r--code/renderer/tr_image_jpg.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/code/renderer/tr_image_jpg.c b/code/renderer/tr_image_jpg.c
index cae7ccb..9add7dd 100644
--- a/code/renderer/tr_image_jpg.c
+++ b/code/renderer/tr_image_jpg.c
@@ -56,6 +56,7 @@ void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height
unsigned row_stride; /* physical row width in output buffer */
unsigned pixelcount, memcount;
unsigned char *out;
+ int len;
byte *fbuffer;
byte *buf;
@@ -65,8 +66,8 @@ void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height
* requires it in order to read binary files.
*/
- ri.FS_ReadFile ( ( char * ) filename, (void **)&fbuffer);
- if (!fbuffer) {
+ len = ri.FS_ReadFile ( ( char * ) filename, (void **)&fbuffer);
+ if (!fbuffer || len < 0) {
return;
}
@@ -84,7 +85,7 @@ void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height
/* Step 2: specify data source (eg, a file) */
- jpeg_stdio_src(&cinfo, fbuffer);
+ jpeg_mem_src(&cinfo, fbuffer, len);
/* Step 3: read file parameters with jpeg_read_header() */