Fix leaking file descriptors on error.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25431 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2010-04-01 22:06:52 +00:00
parent 0d6828e064
commit d6543b71af
2 changed files with 7 additions and 3 deletions

View file

@ -207,10 +207,10 @@ bool EncRbSpeex::encode(QString input,QString output)
}
if ((fout = fopen(output.toLocal8Bit(), "wb")) == NULL) {
qDebug() << "Error: could not open output file\n";
fclose(fin);
return false;
}
int ret = encode_file(fin, fout, quality, complexity, narrowband, volume,
errstr, sizeof(errstr));
fclose(fout);

View file

@ -199,16 +199,19 @@ void VoiceFileCreator::downloadDone(bool error)
return;
}
FILE* output = fopen(QString(m_mountpoint + "/.rockbox/langs/" + m_lang + ".voice").toLocal8Bit(), "wb");
FILE* output = fopen(QString(m_mountpoint + "/.rockbox/langs/" + m_lang
+ ".voice").toLocal8Bit(), "wb");
if (output == NULL)
{
cleanup();
fclose(ids2);
emit logItem(tr("Error opening output file"),LOGERROR);
emit done(true);
return;
}
voicefont(ids2,m_targetid,m_path.toLocal8Bit().data(), output);
// ids2 and output are closed by voicefont().
//cleanup
cleanup();
@ -216,7 +219,8 @@ void VoiceFileCreator::downloadDone(bool error)
// Add Voice file to the install log
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.beginGroup("selfcreated Voice");
installlog.setValue("/.rockbox/langs/" + m_lang + ".voice",QDate::currentDate().toString("yyyyMMdd"));
installlog.setValue("/.rockbox/langs/" + m_lang + ".voice",
QDate::currentDate().toString("yyyyMMdd"));
installlog.endGroup();
installlog.sync();