Commit 6ac9f02b authored by aymeric's avatar aymeric
Browse files

fix descriptor leak and crash when image is 0 sized.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@377 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent ed2635f6
......@@ -83,7 +83,27 @@ mblk_t *ms_load_jpeg_as_yuv(const char *jpgpath, MSVideoSize *reqsize){
#endif
if (fd!=-1){
fstat(fd,&statbuf);
if (statbuf.st_size<=0)
{
#if !defined(_MSC_VER)
close(fd);
#else
_close(fd);
#endif
ms_error("Cannot load %s",jpgpath);
return NULL;
}
jpgbuf=(uint8_t*)alloca(statbuf.st_size);
if (jpgbuf==NULL)
{
#if !defined(_MSC_VER)
close(fd);
#else
_close(fd);
#endif
ms_error("Cannot allocate buffer for %s",jpgpath);
return NULL;
}
#if !defined(_MSC_VER)
read(fd,jpgbuf,statbuf.st_size);
#else
......@@ -93,6 +113,11 @@ mblk_t *ms_load_jpeg_as_yuv(const char *jpgpath, MSVideoSize *reqsize){
}else{
ms_error("Cannot load %s",jpgpath);
}
#if !defined(_MSC_VER)
close(fd);
#else
_close(fd);
#endif
return m;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment