From: lainon Date: Wed, 21 Sep 2022 12:25:11 +0000 (+0300) Subject: Fixed memory leaks X-Git-Tag: 41000~143^2~3 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2cd15502c49b3b743bf471d02a244ce343648bdc;p=francis%2Fwinuae.git Fixed memory leaks --- diff --git a/archivers/wrp/warp.cpp b/archivers/wrp/warp.cpp index cb1c0a12..176af83e 100644 --- a/archivers/wrp/warp.cpp +++ b/archivers/wrp/warp.cpp @@ -95,8 +95,10 @@ static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata { numnodes = xadIOGetBitsLow(&io, 16); - if (io.err) + if (io.err) { + xfree(node); return XADERR_ILLEGALDATA; + } if(numnodes < 0 || numnodes >= ARCSQNUMVALS) err = XADERR_DECRUNCH; diff --git a/debugmem.cpp b/debugmem.cpp index ce129bdc..a182ff86 100644 --- a/debugmem.cpp +++ b/debugmem.cpp @@ -1574,6 +1574,9 @@ static uae_u8 *loadhunkfile(uae_u8 *file, int filelen, uae_u32 seglist, int segm int relochunk = gl(p); p += 4; if (relochunk > last) { + xfree(hunkoffsets); + xfree(hunklens); + xfree(out); return 0; } uaecptr hunkptr = hunkoffsets[relochunk] + relocate_base; @@ -2983,9 +2986,13 @@ static uae_u8 *loadelffile(uae_u8 *file, int filelen, uae_u8 *dbgfile, int debug #endif end: - xfree(lelfs); + if (startp && startseg >= 0) - *startp = lelfs[startseg].dma->start; + if (lelfs) + *startp = lelfs[startseg].dma->start; + + xfree(lelfs); + if (parentidp) *parentidp = parentid; return outp; diff --git a/hardfile.cpp b/hardfile.cpp index 9d8432c2..55484999 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -864,6 +864,7 @@ static int vhd_write_enlarge (struct hardfiledata *hfd, uae_u32 bamoffset) buf = xcalloc (uae_u8, len); if (!hdf_resize_target (hfd, hfd->physsize + len - 512)) { write_log (_T("vhd_enlarge: failure\n")); + xfree(buf); return 0; } // add footer (same as 512 byte header) diff --git a/idecontrollers.cpp b/idecontrollers.cpp index 45ada0cf..4d4b4d27 100644 --- a/idecontrollers.cpp +++ b/idecontrollers.cpp @@ -2308,6 +2308,7 @@ bool trifecta_init(struct autoconfig_info *aci) ide_add_reset(); if (!aci->doinit) { aci->autoconfigp = aci->ert->autoconfig; + xfree(rom); return true; } diff --git a/memory.cpp b/memory.cpp index 9bec083b..2fec4a70 100644 --- a/memory.cpp +++ b/memory.cpp @@ -2060,6 +2060,7 @@ static void add_shmmaps (uae_u32 start, addrbank *what) write_log (_T("NATMEM: Failure to map existing at %08x (%p)\n"), start, base); dumplist (); nocanbang (); + xfree(y); return; } y->next = shm_start; diff --git a/ncr_scsi.cpp b/ncr_scsi.cpp index cae05f5f..4b561246 100644 --- a/ncr_scsi.cpp +++ b/ncr_scsi.cpp @@ -972,8 +972,10 @@ bool ncr710_a4091_autoconfig_init (struct autoconfig_info *aci) } struct ncr_state *ncr = getscsi(aci->rc); - if (!ncr) + if (!ncr) { + xfree(rom); return false; + } xfree(ncr->rom); ncr->rom = rom; diff --git a/od-win32/blkdev_win32_spti.cpp b/od-win32/blkdev_win32_spti.cpp index e91c5dae..bf5ebaa1 100644 --- a/od-win32/blkdev_win32_spti.cpp +++ b/od-win32/blkdev_win32_spti.cpp @@ -870,8 +870,10 @@ static void scanscsi (void) OPEN_EXISTING, // No special create flags 0, // No special attributes NULL); - if (h == INVALID_HANDLE_VALUE) + if (h == INVALID_HANDLE_VALUE) { + xfree(AdapterInfo); return; + } if(!DeviceIoControl (h, IOCTL_SCSI_RESCAN_BUS, diff --git a/pci.cpp b/pci.cpp index f2d8e0ee..2e320e18 100644 --- a/pci.cpp +++ b/pci.cpp @@ -1764,6 +1764,7 @@ bool dkb_wildfire_pci_init(struct autoconfig_info *aci) device_add_reset(pci_reset); if (!aci->doinit) { + xfree(pcib); return true; } @@ -1883,6 +1884,7 @@ static bool grex_pci_init(struct autoconfig_info *aci) device_add_reset(pci_reset); if (!aci->doinit) { + xfree(pcib); return true; } diff --git a/prowizard/rippers/AMOS-MusicBank.c b/prowizard/rippers/AMOS-MusicBank.c index ea330704..fea9b395 100644 --- a/prowizard/rippers/AMOS-MusicBank.c +++ b/prowizard/rippers/AMOS-MusicBank.c @@ -113,6 +113,7 @@ void Depack_AmBk ( void ) if ( j > 1 ) { printf ( "\n!!! unsupported feature in depack_AmBk() - send this file to asle@free.fr !\n" ); + free(Whatever); return; } j = ((in_data[Where+2]*256*256*256)+(in_data[Where+3]*256*256)+(in_data[Where+4]*256)+in_data[Where+5]); diff --git a/prowizard/rippers/TMK.c b/prowizard/rippers/TMK.c index 44e92981..5b692fbd 100644 --- a/prowizard/rippers/TMK.c +++ b/prowizard/rippers/TMK.c @@ -349,5 +349,6 @@ void Depack_TMK ( void ) /*fclose ( info );*/ printf ( "done\n" ); + free( samplesizes ); return; /* useless ... but */ } diff --git a/uaeipc.cpp b/uaeipc.cpp index 71742148..1f5d4dcc 100644 --- a/uaeipc.cpp +++ b/uaeipc.cpp @@ -197,6 +197,7 @@ void *createIPC (const TCHAR *name, int binary) cnt++; continue; } + xfree(ipc); return 0; } break;