mirror of
https://github.com/ioquake/ioq3.git
synced 2025-05-30 16:41:31 +00:00
don't read more memory than available in jpg decode
This commit is contained in:
parent
c77f537ae3
commit
7132b492dd
3 changed files with 30 additions and 10 deletions
|
@ -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() */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue