+2016-02-13 Mark Wielaard <mjw@redhat.com>
+
+ * frame_unwind.c (new_unwound): Check and return unwound.
+ (handle_cfi): Check new_unwound was able to allocate new memory
+ before use. Return DWFL_E_NOMEM otherwise.
+
2016-02-11 Mark Wielaard <mjw@redhat.com>
* relocate.c (relocate_section): Check result of all gelf_get* calls.
/* Get previous frame state for an existing frame state.
- Copyright (C) 2013, 2014 Red Hat, Inc.
+ Copyright (C) 2013, 2014, 2016 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
#undef pop
}
-static void
+static Dwfl_Frame *
new_unwound (Dwfl_Frame *state)
{
assert (state->unwound == NULL);
assert (nregs > 0);
Dwfl_Frame *unwound;
unwound = malloc (sizeof (*unwound) + sizeof (*unwound->regs) * nregs);
+ if (unlikely (unwound == NULL))
+ return NULL;
state->unwound = unwound;
unwound->thread = thread;
unwound->unwound = NULL;
unwound->initial_frame = false;
unwound->pc_state = DWFL_FRAME_STATE_ERROR;
memset (unwound->regs_set, 0, sizeof (unwound->regs_set));
+ return unwound;
}
/* The logic is to call __libdwfl_seterrno for any CFI bytecode interpretation
__libdwfl_seterrno (DWFL_E_LIBDW);
return;
}
- new_unwound (state);
- Dwfl_Frame *unwound = state->unwound;
+
+ Dwfl_Frame *unwound = new_unwound (state);
+ if (unwound == NULL)
+ {
+ __libdwfl_seterrno (DWFL_E_NOMEM);
+ return;
+ }
+
unwound->signal_frame = frame->fde->cie->signal_frame;
Dwfl_Thread *thread = state->thread;
Dwfl_Process *process = thread->process;
Dwfl_Thread *thread = state->thread;
Dwfl_Process *process = thread->process;
Ebl *ebl = process->ebl;
- new_unwound (state);
+ if (new_unwound (state) == NULL)
+ {
+ __libdwfl_seterrno (DWFL_E_NOMEM);
+ return;
+ }
state->unwound->pc_state = DWFL_FRAME_STATE_PC_UNDEFINED;
// &Dwfl_Frame.signal_frame cannot be passed as it is a bitfield.
bool signal_frame = false;