mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 21:28:08 +00:00
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
This commit is contained in:
parent
ed2635f610
commit
6ac9f02b26
1 changed files with 25 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue