Bug 1142757 - Deallocate |inbuf| in the appropriate place to prevent memory leaks and close file streams of |inFile| and |outFile|. r=bwc

--HG--
extra : rebase_source : 117002bd9a156a6e88bad662513919ceba34d85c
This commit is contained in:
Ryan Nath 2015-05-19 12:25:00 -04:00
Родитель 740177a058
Коммит 907168a1cb
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -301,12 +301,15 @@ void AudioSendAndReceive::GenerateAndReadSamples()
FILE* inFile = fopen( iFile.c_str(), "wb+");
if(!inFile) {
cerr << "Input File Creation Failed " << endl;
free(inbuf);
return;
}
FILE* outFile = fopen( oFile.c_str(), "wb+");
if(!outFile) {
cerr << "Output File Creation Failed " << endl;
free(inbuf);
fclose(inFile);
return;
}
@ -323,6 +326,8 @@ void AudioSendAndReceive::GenerateAndReadSamples()
{
if(!memcpy(audioInput.get(), inbuf, sampleLengthInBytes))
{
free(inbuf);
fclose(outFile);
return;
}
@ -350,6 +355,7 @@ void AudioSendAndReceive::GenerateAndReadSamples()
}while(numSamplesReadFromInput < SAMPLES);
FinishWaveHeader(outFile);
free(inbuf);
fclose(outFile);
}