Fix #16613 - Some covs (resource leaks, null ptr deref) (#16670)

* Mostly a bunch of calls to free()
* Make sure columnName isn't dereferenced if null
This commit is contained in:
Ian Huang 2020-04-21 16:27:25 -07:00 committed by GitHub
parent cc9b4a0063
commit b90d469383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 5 deletions

View File

@ -675,6 +675,7 @@ static void database_load_fuzz_file(R2RTestDatabase *db, const char *path, const
}
fuzz_test->file = strdup (file);
if (!fuzz_test->file) {
free (fuzz_test);
return;
}
R2RTest *test = R_NEW (R2RTest);
@ -724,4 +725,4 @@ R_API bool r2r_test_database_load_fuzz(R2RTestDatabase *db, const char *path) {
// Just a single file
database_load_fuzz_file (db, path, path);
return true;
}
}

View File

@ -902,6 +902,7 @@ static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results
free (editor);
editor = strdup ("vim");
if (!editor) {
free (name);
return;
}
}
@ -911,6 +912,7 @@ static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results
char *newcmds = r_file_slurp (name, NULL);
if (!newcmds) {
eprintf ("Failed to read edited command file\n");
free (name);
return;
}
r_str_trim (newcmds);
@ -921,10 +923,12 @@ static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results
newcmds = r_str_newf ("%s\n", newcmds);
free (tmp);
if (!newcmds) {
free (name);
return;
}
}
replace_cmd_kv (result->test->path, test->cmds.line_begin, test->cmds.line_end, "CMDS", newcmds, fixup_results);
free (name);
free (newcmds);
}

View File

@ -1474,6 +1474,7 @@ show_help:
}
break;
default:
pj_free (pj);
r_list_free (list);
goto show_help;
/* not reached */
@ -1483,8 +1484,8 @@ beach:
if (mode == 'j') {
pj_end (pj);
r_cons_printf ("%s\n", pj_string (pj));
pj_free (pj);
}
pj_free (pj);
r_list_free (list);
}

View File

@ -655,6 +655,7 @@ static bool cmd_wfs(RCore *core, const char *input) {
}
ut8 *buf = calloc (1, sz);
if (!buf) {
free (str);
return false;
}
r_io_read_at (core->io, addr, buf, sz);

View File

@ -882,10 +882,12 @@ R_API bool r_table_query(RTable *t, const char *q) {
}
int col = r_table_column_nth (t, columnName);
if (col == -1) {
if (*columnName == '[') {
col = atoi (columnName + 1);
} else if (columnName == NULL && strcmp (operation, "uniq")) {
if (columnName == NULL && strcmp (operation, "uniq")) {
eprintf ("Invalid column name (%s) for (%s)\n", columnName, query);
} else if (columnName) {
if (*columnName == '[') {
col = atoi (columnName + 1);
}
}
}
if (!operation) {