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
+11 -11
View File
@@ -130,19 +130,19 @@ MidiSettingsView::_LoadSettings()
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE);
BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() == B_OK)
if (file.InitCheck() == B_OK) {
file.Read(buffer, sizeof(buffer));
}
char soundFont[512];
sscanf(buffer, "# Midi Settings\n soundfont = %s\n",
soundFont);
char soundFont[512];
sscanf(buffer, "# Midi Settings\n soundfont = %s\n",
soundFont);
for (int32 i = 0; i < fListView->CountItems(); i++) {
BStringItem* item = (BStringItem*)fListView->ItemAt(i);
if (!strcmp(item->Text(), soundFont)) {
fListView->Select(i);
break;
for (int32 i = 0; i < fListView->CountItems(); i++) {
BStringItem* item = (BStringItem*)fListView->ItemAt(i);
if (!strcmp(item->Text(), soundFont)) {
fListView->Select(i);
break;
}
}
}
}
}