Merge pull request #35 from michaelDCurran/loadSpectSeq_fclose

Stop leaking file streams in libespeak-ng's LoadSpectSeq function.
This commit is contained in:
Reece Dunn
2015-12-17 12:36:33 +00:00
+7 -1
View File
@@ -339,6 +339,7 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
else else
{ {
fprintf(stderr, "Unsupported spectral file format.\n"); fprintf(stderr, "Unsupported spectral file format.\n");
fclose(stream);
return(1); return(1);
} }
@@ -356,7 +357,11 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
fread(&spect->max_y,sizeof(short),1,stream); fread(&spect->max_y,sizeof(short),1,stream);
fread(&temp,sizeof(short),1,stream); // unused fread(&temp,sizeof(short),1,stream); // unused
if(n==0) return(0); if(n==0)
{
fclose(stream);
return(0);
}
if(spect->frames != NULL) if(spect->frames != NULL)
{ {
@@ -417,5 +422,6 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
if(spect->frames[ix]->keyframe) if(spect->frames[ix]->keyframe)
spect->frames[ix]->length_adjust = spect->frames[ix]->length - GetFrameLength(spect,ix); spect->frames[ix]->length_adjust = spect->frames[ix]->length - GetFrameLength(spect,ix);
} }
fclose(stream);
return(0); return(0);
} }