summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/repacketizer_demo.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/repacketizer_demo.c b/src/repacketizer_demo.c
index dc05c1b3..43de7019 100644
--- a/src/repacketizer_demo.c
+++ b/src/repacketizer_demo.c
@@ -119,7 +119,19 @@ int main(int argc, char *argv[])
for (i=0;i<nb_packets;i++)
{
unsigned char ch[4];
- err = fread(ch, 1, 4, fin);
+ if (fread(ch, 1, 4, fin)!=4)
+ {
+ if (feof(fin))
+ {
+ eof = 1;
+ } else {
+ fprintf(stderr, "Error reading payload length.\n");
+ fclose(fin);
+ fclose(fout);
+ return EXIT_FAILURE;
+ }
+ break;
+ }
len[i] = char_to_int(ch);
/*fprintf(stderr, "in len = %d\n", len[i]);*/
if (len[i]>1500 || len[i]<0)
@@ -135,13 +147,31 @@ int main(int argc, char *argv[])
}
break;
}
- err = fread(ch, 1, 4, fin);
- rng[i] = char_to_int(ch);
- err = fread(packets[i], 1, len[i], fin);
- if (feof(fin))
+ if (fread(ch, 1, 4, fin)!=4)
{
- eof = 1;
- break;
+ if (feof(fin))
+ {
+ eof = 1;
+ } else {
+ fprintf(stderr, "Error reading.\n");
+ fclose(fin);
+ fclose(fout);
+ return EXIT_FAILURE;
+ }
+ break;
+ }
+ rng[i] = char_to_int(ch);
+ if (fread(packets[i], len[i], 1, fin)!=1) {
+ if (feof(fin))
+ {
+ eof = 1;
+ } else {
+ fprintf(stderr, "Error reading packet of %u bytes.\n", len[i]);
+ fclose(fin);
+ fclose(fout);
+ return EXIT_FAILURE;
+ }
+ break;
}
err = opus_repacketizer_cat(rp, packets[i], len[i]);
if (err!=OPUS_OK)