Skip to content

Commit f9ed625

Browse files
committed
Fix #8. Check Value of fread
1 parent eea29da commit f9ed625

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/muxer/bbfmux.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ char* readTxtFile(const char* fPath)
6060
if(!file)
6161
{
6262
// can't open file
63+
printf("[BBFMUX] Unable to read text file: %s", fPath);
6364
return 0;
6465
}
6566

@@ -68,7 +69,14 @@ char* readTxtFile(const char* fPath)
6869
fseek(file, 0, SEEK_SET);
6970

7071
char* cString = (char*)malloc(fileSize + 1);
71-
fread(cString, 1, fileSize, file);
72+
size_t readSize = fread(cString, 1, fileSize, file);
73+
74+
if (readSize != fileSize)
75+
{
76+
printf("[BBFMUX] Unable to read text file: %s", fPath);
77+
return 0;
78+
}
79+
7280
fclose(file);
7381

7482
cString[fileSize] = 0;

0 commit comments

Comments
 (0)