handle return of fread
This commit is contained in:
parent
0a720f056a
commit
d0e98eb3f1
2 changed files with 6 additions and 2 deletions
|
@ -555,7 +555,7 @@ namespace agg
|
||||||
if(len > 0)
|
if(len > 0)
|
||||||
{
|
{
|
||||||
m_loaded_font.resize(len);
|
m_loaded_font.resize(len);
|
||||||
if (fread(&m_loaded_font[0], 1, len, fd) == 1)
|
if (fread(&m_loaded_font[0], 1, len, fd) == len)
|
||||||
{
|
{
|
||||||
m_font = &m_loaded_font[0];
|
m_font = &m_loaded_font[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,11 @@ void png_reader::init()
|
||||||
if (!fp) throw image_reader_exception("cannot open image file "+fileName_);
|
if (!fp) throw image_reader_exception("cannot open image file "+fileName_);
|
||||||
png_byte header[8];
|
png_byte header[8];
|
||||||
memset(header,0,8);
|
memset(header,0,8);
|
||||||
fread(header,1,8,fp);
|
if ( fread(header,1,8,fp) != 8)
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
throw image_reader_exception("Could not read " + fileName_);
|
||||||
|
}
|
||||||
int is_png=!png_sig_cmp(header,0,8);
|
int is_png=!png_sig_cmp(header,0,8);
|
||||||
if (!is_png)
|
if (!is_png)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue