On Friday 01 June 2007 13:39:32 Mehmet Yavuz Selim Soyturk wrote:
> Function mmd_expand_y in src/mmd.c allocates new memory for the mmd
> table, but does not initialize the newy allocated memory to NULL,
> which causes segfaults for some cases. The attached patch solves that
> problem.
I thought that might happen. I prefer this memset() patch, but if it doesn't
work everywhere, your patch should work.
-- c
=== src/mmd.c
==================================================================
--- src/mmd.c (revision 3732)
+++ src/mmd.c (local)
@@ -623,19 +623,22 @@
static void
mmd_expand_y(Interp *interp, INTVAL func_nr, INTVAL new_y)
{
- funcptr_t *new_table;
- UINTVAL new_size;
+ UINTVAL new_size, i, x, y;
MMD_table * const table = interp->binop_mmd_funcs + func_nr;
assert(table->x);
- new_size = sizeof (funcptr_t) * table->x * new_y;
+ x = table->x;
+ y = table->y;
+ new_size = sizeof (funcptr_t) * x * new_y;
if (table->mmd_funcs)
table->mmd_funcs = mem_sys_realloc(table->mmd_funcs, new_size);
else
table->mmd_funcs = (funcptr_t *)mem_sys_allocate(new_size);
+ memset(table->mmd_funcs + x * y, 0, x * (new_y - y));
+
table->y = new_y;
}