summaryrefslogtreecommitdiff
path: root/lib/elf_py.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elf_py.c')
-rw-r--r--lib/elf_py.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/elf_py.c b/lib/elf_py.c
index d473dc10cb..643495d8c7 100644
--- a/lib/elf_py.c
+++ b/lib/elf_py.c
@@ -1089,7 +1089,9 @@ static void elffile_add_dynreloc(struct elffile *w, Elf_Data *reldata,
symidx = relw->symidx = GELF_R_SYM(rela->r_info);
sym = relw->sym = gelf_getsym(symdata, symidx, &relw->_sym);
if (sym) {
- relw->symname = elfdata_strptr(strdata, sym->st_name);
+ if (strdata)
+ relw->symname = elfdata_strptr(strdata,
+ sym->st_name);
relw->symvalid = GELF_ST_TYPE(sym->st_info)
!= STT_NOTYPE;
relw->unresolved = sym->st_shndx == SHN_UNDEF;
@@ -1140,7 +1142,7 @@ static PyObject *elffile_load(PyTypeObject *type, PyObject *args,
fd = open(filename, O_RDONLY | O_NOCTTY);
if (fd < 0 || fstat(fd, &st)) {
PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename);
- if (fd > 0)
+ if (fd >= 0)
close(fd);
goto out;
}