]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fixed memory leaks
authorlainon <GermanAizek@yandex.ru>
Wed, 21 Sep 2022 12:25:11 +0000 (15:25 +0300)
committerlainon <GermanAizek@yandex.ru>
Wed, 21 Sep 2022 12:25:11 +0000 (15:25 +0300)
archivers/wrp/warp.cpp
debugmem.cpp
hardfile.cpp
idecontrollers.cpp
memory.cpp
ncr_scsi.cpp
od-win32/blkdev_win32_spti.cpp
pci.cpp
prowizard/rippers/AMOS-MusicBank.c
prowizard/rippers/TMK.c
uaeipc.cpp

index cb1c0a12b5e63bba0193fad14e9954325c8061af..176af83ee332200999caeb8d965ad669fdf9a1f4 100644 (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;
index ce129bdc7de9939d0bd5dbd320783531a6ecb090..a182ff86f2745ec5de3383bb47f29b7e3d7a363b 100644 (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;
index 9d8432c2d9d5a32469be66951a528dbc2e1ae9bf..554849992517f73181d82c5e91d53ea158df22c7 100644 (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)
index 45ada0cfa039c20c73aa263ed95a42dbea555492..4d4b4d275628cefe717d49e8d780326b94fcf18c 100644 (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;
        }
 
index 9bec083bd8d5beab80003c40639df7c44baa3372..2fec4a708922c373bbb3a97061004c77a660b936 100644 (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;
index cae05f5f79f5763a05abceea7367bc4715694863..4b5612466c9af892de36e663d7e85c6bbe4def88 100644 (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;
index e91c5daeca9028f8343d6bd9f2be5cba90a03d14..bf5ebaa16e31b09e7e749ac09cc466680828264e 100644 (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,
diff --git a/pci.cpp b/pci.cpp
index f2d8e0eed0d5267c415907dc6cfab46287b6a289..2e320e18db84086f14646a93a99ffe74962af11b 100644 (file)
--- 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;
        }
 
index ea3307040454064ff601ec404b0b66b89da83a04..fea9b395b9e595cb960d3a480539c7040ea335ad 100644 (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]);
index 44e929816c03ada4145ff84512782749ea159205..5b692fbd366ea2352ea4a2a5d4ef1e5c20f16c95 100644 (file)
@@ -349,5 +349,6 @@ void Depack_TMK ( void )
   /*fclose ( info );*/
 
   printf ( "done\n" );
+  free( samplesizes );
   return; /* useless ... but */
 }
index 7174214855acc5d200b87fffe17deb207c06ff97..1f5d4dcc505ac40c23b8d0dde26498926b758b0a 100644 (file)
@@ -197,6 +197,7 @@ void *createIPC (const TCHAR *name, int binary)
                                cnt++;
                                continue;
                        }
+                       xfree(ipc);
                        return 0;
                }
                break;