CID 1249930: Don't scanf uninitialized buffer

Would happen in case of a missing config file, for instance.
This commit is contained in:
Philippe Saint-Pierre
2015-06-25 19:29:13 -04:00
parent 6b05e9db3d
commit 1443b2798f
+3 -3
View File
@@ -130,10 +130,8 @@ MidiSettingsView::_LoadSettings()
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE); path.Append(SETTINGS_FILE);
BFile file(path.Path(), B_READ_ONLY); BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() == B_OK) if (file.InitCheck() == B_OK) {
file.Read(buffer, sizeof(buffer)); file.Read(buffer, sizeof(buffer));
}
char soundFont[512]; char soundFont[512];
sscanf(buffer, "# Midi Settings\n soundfont = %s\n", sscanf(buffer, "# Midi Settings\n soundfont = %s\n",
soundFont); soundFont);
@@ -146,6 +144,8 @@ MidiSettingsView::_LoadSettings()
} }
} }
} }
}
}
void void