Avoid fwrite failure while trying to write empty missing helpers string

This commit is contained in:
Jean-Francois Dockes 2011-09-20 07:37:28 +02:00
parent 2c2c0dadf2
commit cd27645cc2

View File

@ -590,7 +590,7 @@ void RclConfig::storeMissingHelperDesc(const string &s)
string fmiss = path_cat(getConfDir(), "missing");
FILE *fp = fopen(fmiss.c_str(), "w");
if (fp) {
if (fwrite(s.c_str(), s.size(), 1, fp) != 1) {
if (s.size() > 0 && fwrite(s.c_str(), s.size(), 1, fp) != 1) {
LOGERR(("storeMissingHelperDesc: fwrite failed\n"));
}
fclose(fp);