Browse Source

handle file IO error

shared-context
lieff 8 years ago
parent
commit
ecb5899bcf
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/fontstash.h

+ 3
- 2
src/fontstash.h View File

@@ -873,7 +873,7 @@ error:
int fonsAddFont(FONScontext* stash, const char* name, const char* path)
{
FILE* fp = 0;
int dataSize = 0;
int dataSize = 0, readed;
unsigned char* data = NULL;

// Read in the font data.
@@ -884,9 +884,10 @@ int fonsAddFont(FONScontext* stash, const char* name, const char* path)
fseek(fp,0,SEEK_SET);
data = (unsigned char*)malloc(dataSize);
if (data == NULL) goto error;
fread(data, 1, dataSize, fp);
readed = fread(data, 1, dataSize, fp);
fclose(fp);
fp = 0;
if (readed != dataSize) goto error;

return fonsAddFontMem(stash, name, data, dataSize, 1);



Loading…
Cancel
Save