Fix coverity issues (and some PE tests \o/)

This commit is contained in:
jvoisin 2014-07-24 02:04:58 +02:00
parent f6f48553cd
commit 8fdfefb080
3 changed files with 13 additions and 6 deletions

View File

@ -48,7 +48,7 @@ static ut64 baddr(RBinFile *arch) {
}
static RBinAddr* binsym(RBinFile *arch, int type) {
struct r_bin_pe_addr_t *peaddr;
struct r_bin_pe_addr_t *peaddr = NULL;
RBinAddr *ret = NULL;
if (arch && arch->o && arch->o->bin_obj)
switch (type) {
@ -60,6 +60,7 @@ static RBinAddr* binsym(RBinFile *arch, int type) {
ret->paddr = peaddr->paddr;
ret->vaddr = peaddr->vaddr;
}
free (peaddr);
return ret;
}

View File

@ -209,7 +209,7 @@ R_API int r_lang_prompt(RLang *lang) {
char *p = r_line_readline ();
if (!p) break;
r_line_hist_add (p);
strncpy (buf, p, sizeof(buf));
strncpy (buf, p, sizeof(buf) - 1);
if (*buf == '!') {
r_sandbox_system (buf+1, 1);
continue;

View File

@ -1087,8 +1087,11 @@ R_API RBinJavaField* r_bin_java_read_next_method(RBinJavaObj *bin, const ut64 of
const ut8 * f_buf = buf + offset;
ut64 adv = 0;
RBinJavaCPTypeObj *item = NULL;
RBinJavaField *method = (RBinJavaField *) R_NEW0(RBinJavaField);
if (bin == NULL || method == NULL || method->metas == NULL) {
RBinJavaField *method;
if (bin == NULL)
return NULL;
method = (RBinJavaField *) R_NEW0(RBinJavaField);
if (method == NULL) {
eprintf ("Unable to allocate memory for method information\n");
return NULL;
}
@ -1183,8 +1186,11 @@ R_API RBinJavaField* r_bin_java_read_next_field(RBinJavaObj *bin, const ut64 off
RBinJavaCPTypeObj *item = NULL;
const ut8 *f_buf = buffer + offset;
ut64 adv = 0;
RBinJavaField *field = (RBinJavaField *) R_NEW0(RBinJavaField);
if (bin == NULL || field == NULL) {
RBinJavaField *field;
if (bin == NULL)
return NULL;
field = (RBinJavaField *) R_NEW0(RBinJavaField);
if (field == NULL) {
eprintf ("Unable to allocate memory for field information\n");
return NULL;
}