You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/media-libs/libmikmod/files/3.2.0/004_all_malloc-fail.patch

23 lines
681 B

http://pkgs.fedoraproject.org/cgit/libmikmod.git/tree/libmikmod-malloc-fail.patch
Some partially corrupt mod files cause mikmod to try and allocate lots
of memory, this is ok, because failure to do so is being handled.
But the new libmikmod malloc code align_pointer function did not handle
asking to align the NULL pointer, resulting from the too big alloc,
causing a segfault, this patch fixes this.
--- mmio/mmalloc.c
+++ mmio/mmalloc.c
@@ -38,6 +38,10 @@ static void * align_pointer(char *ptr, s
{
char *pptr = ptr + sizeof(void*);
char *fptr;
+
+ if (ptr == NULL)
+ return NULL;
+
size_t err = ((size_t)pptr)&(stride-1);
if (err)
fptr = pptr + (stride - err);