Fixed memory leaks

This commit is contained in:
lainon 2022-09-21 15:25:11 +03:00
parent 181d9265a1
commit 2cd15502c4
11 changed files with 26 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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;
}

View File

@ -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]);

View File

@ -349,5 +349,6 @@ void Depack_TMK ( void )
/*fclose ( info );*/
printf ( "done\n" );
free( samplesizes );
return; /* useless ... but */
}

View File

@ -197,6 +197,7 @@ void *createIPC (const TCHAR *name, int binary)
cnt++;
continue;
}
xfree(ipc);
return 0;
}
break;