* Segfault in latest pahole
@ 2008-12-19 14:21 Emmanuel Viaud
0 siblings, 0 replies; only message in thread
From: Emmanuel Viaud @ 2008-12-19 14:21 UTC (permalink / raw)
To: dwarves-u79uwXL29TY76Z2rM5mHXA
Hi.
I got a segfault using latest head of pahole. The problems comes from
the memcpy call in gobuffer_add function when the entry to add has a
size larger than GOBUFFER__BCHUNK (the entry was 16299 bytes long in
my example). In that case, the realloc (which only allocates
GOBUFFER_BCHUNK bytes) does not allocate enough memory.
The simple following patch solves my problem, but I don't know if it
is good enough:
diff --git a/gobuffer.c b/gobuffer.c
index 5797aa6..d3f4726 100644
--- a/gobuffer.c
+++ b/gobuffer.c
@@ -63,7 +63,7 @@ unsigned int gobuffer__add(struct gobuffer *self,
const void *s,
const unsigned int index = self->index + len;
char *copy;
- if (index >= self->allocated_size) {
+ while (index >= self->allocated_size) {
const unsigned int allocated_size = (self->allocated_size +
GOBUFFER__BCHUNK);
char *entries = realloc(self->entries, allocated_size);
Thanks and best regards.
Emmanuel
--
To unsubscribe from this list: send the line "unsubscribe dwarves" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-19 14:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-19 14:21 Segfault in latest pahole Emmanuel Viaud
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).