Fix crash in r2panels config

This commit is contained in:
KoWu 2019-05-07 22:25:26 +02:00 committed by radare
parent 8afa731a2f
commit 9a1965f73e

View File

@ -3618,6 +3618,8 @@ static void savePanelsLayout(RPanels* panels) {
}
static char *parsePanelsConfig(const char *cfg, int len) {
for(len = strlen(cfg); len && cfg[len] != ']'; len--);
if (!cfg || !*cfg || len < 2 || *cfg != '[') {
eprintf ("Not valid config!\n");
return NULL;
@ -3639,6 +3641,8 @@ static char *parsePanelsConfig(const char *cfg, int len) {
return NULL;
}
}
tmp[len] = 0;
return tmp;
}
@ -3660,10 +3664,10 @@ static int loadSavedPanelsLayout(RCore *core) {
panelsConfig = r_file_slurp (configPath, &s);
free (configPath);
if (!panelsConfig) {
free (panelsConfig);
return 0;
}
char *parsedConfig = parsePanelsConfig (panelsConfig, strlen (panelsConfig));
char *parsedConfig = parsePanelsConfig (panelsConfig, s);
free (panelsConfig);
if (!parsedConfig) {
return 0;