Browse Source

Fix truncated fgetc return value in LoadWavefile(compiledata.c). [Coverity]

master
Reece H. Dunn 9 years ago
parent
commit
4ec98f79a8
1 changed files with 11 additions and 4 deletions
  1. 11
    4
      src/libespeak-ng/compiledata.c

+ 11
- 4
src/libespeak-ng/compiledata.c View File

#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
// data contains: 4 bytes of length (n_samples * 2), followed by 2-byte samples (lsb byte first) // data contains: 4 bytes of length (n_samples * 2), followed by 2-byte samples (lsb byte first)
length = Read4Bytes(f); length = Read4Bytes(f);


while (!feof(f)) {
c1 = fgetc(f);
c3 = fgetc(f);
if (feof(f)) break;
while (true) {
int c;

if ((c = fgetc(f)) == EOF)
break;
c1 = (unsigned char)c;

if ((c = fgetc(f)) == EOF)
break;
c3 = (unsigned char)c;


c2 = c3 << 24; c2 = c3 << 24;
c2 = c2 >> 16; // sign extend c2 = c2 >> 16; // sign extend

Loading…
Cancel
Save