# HG changeset patch # User Pascal Bellard # Date 1566726086 -7200 # Node ID f063a9bbc7f4bcb352a59e8566cabc172490853c # Parent 8637af3e2aba0ff71a5967fa09a3f7bd78c29aec syslinux/kbd: check kbd malloc pointer diff -r 8637af3e2aba -r f063a9bbc7f4 syslinux/stuff/extra/md5sum.c --- a/syslinux/stuff/extra/md5sum.c Sun Aug 25 11:13:41 2019 +0200 +++ b/syslinux/stuff/extra/md5sum.c Sun Aug 25 11:41:26 2019 +0200 @@ -626,13 +626,15 @@ loadfile(kbdfile, (void **) &kbdmap, &map_size)) goto kbdmap_error; if (* (short *) kbdmap == 0x005D) { + void *heap = malloc(2*(1846 + (768 << (3 + 0))) + 16); void *p = malloc(map_size = * (long *) (kbdmap + 5)); - void *heap = malloc(2*(1846 + (768 << (3 + 0))) + 16); - unlzma(kbdmap, p, heap); - free(heap); - free(kbdmap); - kbdmap = p; + if (p) { + unlzma(kbdmap, p, heap); + free(heap); + free(kbdmap); + kbdmap = p; + } } if (strncmp(kbdmap, "07070", 5)) goto kbdmap_error;