Segfault in latest pahole

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux