Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed JpegIo thumbnail creation to use malloc/free for dest buffer #1046

Merged
merged 1 commit into from Jun 6, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions xbmc/guilib/JpegIO.cpp
Expand Up @@ -436,7 +436,7 @@ bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int wid
struct my_error_mgr jerr;
JSAMPROW row_pointer[1];
long unsigned int outBufSize = 0;
unsigned char* result = new unsigned char [(width * height)]; //Initial buffer. Grows as-needed.
unsigned char* result;
unsigned char* src = buffer;
unsigned char* rgbbuf, *src2, *dst2;

Expand All @@ -446,6 +446,13 @@ bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int wid
return false;
}

result = (unsigned char*) malloc(width * height); //Initial buffer. Grows as-needed.
if (result == NULL)
{
CLog::Log(LOGERROR, "JpegIO::CreateThumbnailFromSurface error allocating memory for image buffer");
return false;
}

if(format == XB_FMT_RGB8)
{
rgbbuf = buffer;
Expand Down Expand Up @@ -482,7 +489,7 @@ bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int wid
if (setjmp(jerr.setjmp_buffer))
{
jpeg_destroy_compress(&cinfo);
delete [] result;
free(result);
if(format != XB_FMT_RGB8)
delete [] rgbbuf;
return false;
Expand Down Expand Up @@ -519,10 +526,10 @@ bool CJpegIO::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int wid
{
file.Write(result, outBufSize);
file.Close();
delete [] result;
free(result);
return true;
}
delete [] result;
free(result);
return false;
}

Expand Down