Mercurial > hg > dmlib
changeset 834:9623b9b548d4
Reallocation fixes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 Jul 2014 18:06:30 +0300 |
parents | 4f3828914890 |
children | a75ffe7a02b9 |
files | src/dmtimelinew.c src/libgfx.c |
diffstat | 2 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmtimelinew.c Fri Jul 11 18:02:59 2014 +0300 +++ b/src/dmtimelinew.c Fri Jul 11 18:06:30 2014 +0300 @@ -228,10 +228,11 @@ if (tl->ntracks + 1 >= tl->nallocated) { + void *ptmp = dmRealloc(tl->tracks, sizeof(DMTimelineTrack *) * (tl->nallocated + 16)); + if (ptmp == NULL) + return DMERR_MALLOC; tl->nallocated += 16; - tl->tracks = dmRealloc(tl->tracks, sizeof(DMTimelineTrack *) * tl->nallocated); - if (tl->tracks == NULL) - return DMERR_MALLOC; + tl->tracks = ptmp; } tl->tracks[tl->ntracks] = track; @@ -253,10 +254,11 @@ if (track->nevents + 1 >= track->nallocated) { + void *ptmp = dmRealloc(track->events, sizeof(DMTimelineEvent *) * (track->nallocated + 16)); + if (ptmp == NULL) + return DMERR_MALLOC; track->nallocated += 16; - track->events = dmRealloc(track->events, sizeof(DMTimelineEvent *) * track->nallocated); - if (track->events == NULL) - return DMERR_MALLOC; + track->events = ptmp; } track->events[track->nevents] = ev;
--- a/src/libgfx.c Fri Jul 11 18:02:59 2014 +0300 +++ b/src/libgfx.c Fri Jul 11 18:06:30 2014 +0300 @@ -1639,14 +1639,22 @@ // If halfbrite is used, duplicate the palette if (iff.camg & IFF_CAMG_HALFBRITE) { + void *ptmp; + if (iff.ncolors > 128) { dmError("ILBM: Halfbrite enabled, but ncolors > 128.\n"); return DMERR_NOT_SUPPORTED; } - if ((iff.pal = dmRealloc(iff.pal, sizeof(DMColor) * iff.ncolors * 2)) == NULL) + if ((ptmp = dmRealloc(iff.pal, sizeof(DMColor) * iff.ncolors * 2)) == NULL) + { + dmFree(iff.pal); + iff.pal = NULL; return DMERR_MALLOC; + } + else + iff.pal = ptmp; for (i = 0; i < iff.ncolors; i++) {