Fix two minor leaks spotted by coverity

This commit is contained in:
Sergi Àlvarez i Capilla 2022-02-26 13:46:46 +01:00
parent 3e656374ed
commit 7f472c50eb
2 changed files with 17 additions and 17 deletions

View File

@ -985,6 +985,7 @@ static Sdb *store_versioninfo_gnu_verdef(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz)
}
Sdb *sdb = sdb_new0 ();
if (!sdb) {
free (defs);
return false;
}
size_t shsize = shdr->sh_size;

View File

@ -4719,24 +4719,23 @@ static void print_json_string(RCore *core, const char* block, int len, const cha
slen = strlen (tblock);
}
PJ *pj = r_core_pj_new (core);
if (!pj) {
return;
if (pj) {
pj_o (pj);
pj_k (pj, "string");
// TODO: add pj_kd for data to pass key(string) and value(data,len) instead of pj_ks which null terminates
char *str = r_str_utf16_encode (tblock, slen); // XXX just block + len should be fine, pj takes care of this
pj_raw (pj, "\"");
pj_raw (pj, str);
free (str);
pj_raw (pj, "\"");
pj_kn (pj, "offset", core->offset);
pj_ks (pj, "section", section_name);
pj_ki (pj, "length", slen);
pj_ks (pj, "type", type);
pj_end (pj);
r_cons_println (pj_string (pj));
pj_free (pj);
}
pj_o (pj);
pj_k (pj, "string");
// TODO: add pj_kd for data to pass key(string) and value(data,len) instead of pj_ks which null terminates
char *str = r_str_utf16_encode (tblock, slen); // XXX just block + len should be fine, pj takes care of this
pj_raw (pj, "\"");
pj_raw (pj, str);
free (str);
pj_raw (pj, "\"");
pj_kn (pj, "offset", core->offset);
pj_ks (pj, "section", section_name);
pj_ki (pj, "length", slen);
pj_ks (pj, "type", type);
pj_end (pj);
r_cons_println (pj_string (pj));
pj_free (pj);
if (tblock != block) {
free (tblock);
}