From 8f37d8b889225b9d5e9ca21bc8298daf3e9ae771 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 6 Mar 2018 21:27:03 +0200 Subject: [PATCH] More analyzer fixes. --- expansion.cpp | 18 ++++++++++-------- od-win32/hardfile_win32.cpp | 2 +- od-win32/mp3decoder.cpp | 4 ++-- od-win32/win32.cpp | 2 +- od-win32/win32gui.cpp | 18 +++++++++--------- scsitape.cpp | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/expansion.cpp b/expansion.cpp index cd2ad886..a11e0a27 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -314,18 +314,20 @@ static void addextrachip (uae_u32 sysbase) uae_u32 first = get_long (ml + 16); put_long (ml + 24, currprefs.chipmem_size); // mh_Upper put_long (ml + 28, get_long (ml + 28) + added); // mh_Free - uae_u32 next; + uae_u32 next = 0; while (first) { next = first; first = get_long (next); } - uae_u32 bytes = get_long (next + 4); - if (next + bytes == 0x00200000) { - put_long (next + 4, currprefs.chipmem_size - next); - } else { - put_long (0x00200000 + 0, 0); - put_long (0x00200000 + 4, added); - put_long (next, 0x00200000); + if (next) { + uae_u32 bytes = get_long(next + 4); + if (next + bytes == 0x00200000) { + put_long(next + 4, currprefs.chipmem_size - next); + } else { + put_long(0x00200000 + 0, 0); + put_long(0x00200000 + 4, added); + put_long(next, 0x00200000); + } } return; } diff --git a/od-win32/hardfile_win32.cpp b/od-win32/hardfile_win32.cpp index 3302865f..5365bddd 100644 --- a/od-win32/hardfile_win32.cpp +++ b/od-win32/hardfile_win32.cpp @@ -923,7 +923,7 @@ static bool hd_get_meta_hack(HWND hDlg, HANDLE h, uae_u8 *data, uae_u8 *inq, str uae_u8 cmd[16]; memset(data, 0, 512); - if (udi->usb_vid == 0x152d && (udi->usb_pid == 0x2329 && udi->usb_pid == 0x2336 || udi->usb_pid == 0x2338 || udi->usb_pid == 0x2339)) { + if (udi->usb_vid == 0x152d && (udi->usb_pid == 0x2329 || udi->usb_pid == 0x2336 || udi->usb_pid == 0x2338 || udi->usb_pid == 0x2339)) { return hd_meta_hack_jmicron(h, data, inq); } if (!hDlg) diff --git a/od-win32/mp3decoder.cpp b/od-win32/mp3decoder.cpp index 64987bc7..8a128fca 100644 --- a/od-win32/mp3decoder.cpp +++ b/od-win32/mp3decoder.cpp @@ -147,8 +147,8 @@ mp3decoder::mp3decoder(struct zfile *zf) { MMRESULT mmr; LPWAVEFORMATEX waveFormat, inwave; - LPMPEGLAYER3WAVEFORMAT mp3format; - LPMPEG1WAVEFORMAT mp2format; + LPMPEGLAYER3WAVEFORMAT mp3format = NULL; + LPMPEG1WAVEFORMAT mp2format = NULL; DWORD maxFormatSize; struct mpegaudio_header head; diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index a38c1a85..bdd72601 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -5766,7 +5766,7 @@ static TCHAR *getdefaultini (int *tempfile) int v = GetTempPath (sizeof path / sizeof (TCHAR), path); if (v == 0 || v > sizeof path / sizeof (TCHAR)) return my_strdup (orgpath); - _tcsncat (path, _T("winuae.ini"), sizeof path / sizeof (TCHAR)); + _tcsncat (path, _T("winuae.ini"), sizeof path / sizeof (TCHAR) - _tcslen(path)); f = _tfopen (path, _T("w")); if (f) { fclose (f); diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 889d7539..5adf2b8d 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -2732,14 +2732,14 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs WIN32GUI_LoadUIString (IDS_SELECTADF, szTitle, MAX_DPATH); WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH); _stprintf (szFilter, _T("%s "), szFormat); - memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING)); defext = _T("adf"); break; case 22: _tcscpy(szTitle, prefs->floppyslots[wParam - IDC_DF0].df); WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH); _stprintf (szFilter, _T("%s "), szFormat); - memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING)); defext = _T("adf"); break; case 1: @@ -2754,7 +2754,7 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs WIN32GUI_LoadUIString (IDS_SELECTHDF, szTitle, MAX_DPATH); WIN32GUI_LoadUIString (IDS_HDF, szFormat, MAX_DPATH); _stprintf (szFilter, _T("%s "), szFormat); - memcpy (szFilter + _tcslen (szFilter), HDF_FORMAT_STRING, sizeof (HDF_FORMAT_STRING) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), HDF_FORMAT_STRING, sizeof (HDF_FORMAT_STRING)); defext = _T("hdf"); break; case 4: @@ -2769,7 +2769,7 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs WIN32GUI_LoadUIString (IDS_SELECTROM, szTitle, MAX_DPATH); WIN32GUI_LoadUIString (IDS_ROM, szFormat, MAX_DPATH); _stprintf (szFilter, _T("%s "), szFormat); - memcpy (szFilter + _tcslen (szFilter), ROM_FORMAT_STRING, sizeof (ROM_FORMAT_STRING) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), ROM_FORMAT_STRING, sizeof (ROM_FORMAT_STRING)); defext = _T("rom"); break; case 7: @@ -2784,7 +2784,7 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs WIN32GUI_LoadUIString (flag == 15 ? IDS_RESTOREINP : IDS_SAVEINP, szTitle, MAX_DPATH); WIN32GUI_LoadUIString (IDS_INP, szFormat, MAX_DPATH); _stprintf (szFilter, _T("%s "), szFormat); - memcpy (szFilter + _tcslen (szFilter), INP_FORMAT_STRING, sizeof (INP_FORMAT_STRING) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), INP_FORMAT_STRING, sizeof (INP_FORMAT_STRING)); defext = _T("inp"); break; case 9: @@ -2793,11 +2793,11 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs WIN32GUI_LoadUIString (IDS_USS, szFormat, MAX_DPATH); _stprintf (szFilter, _T("%s "), szFormat); if (flag == 10) { - memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_RESTORE, sizeof (USS_FORMAT_STRING_RESTORE) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_RESTORE, sizeof (USS_FORMAT_STRING_RESTORE)); all = 1; } else { TCHAR tmp[MAX_DPATH]; - memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_SAVE, sizeof (USS_FORMAT_STRING_SAVE) + sizeof (TCHAR)); + memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_SAVE, sizeof (USS_FORMAT_STRING_SAVE)); p = szFilter; while (p[0] != 0 || p[1] !=0 ) p++; p++; @@ -5088,7 +5088,7 @@ static INT_PTR CALLBACK InfoSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LP break; } - GetDlgItemText(hDlg, IDC_PATH_NAME, workprefs.info, sizeof workprefs.info); + GetDlgItemText(hDlg, IDC_PATH_NAME, workprefs.info, sizeof workprefs.info / sizeof(TCHAR)); recursive--; break; } @@ -19381,7 +19381,7 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam) *p++ = 0; *p++ = 0; if (p[0] == ' ') - *p++; + *p++ = 0; if (p[0] == '#') imageid = _tstol (p + 1); tmp[_tcslen (tmp) - 1] = 0; diff --git a/scsitape.cpp b/scsitape.cpp index 22b310e1..bc0bde07 100644 --- a/scsitape.cpp +++ b/scsitape.cpp @@ -51,11 +51,11 @@ void tape_free (struct scsi_data_tape *tape) zfile_fclose (tape->zf); zfile_fclose (tape->index); zfile_closedir_archive (tape->zd); - xfree(tape); for (int i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (tapeunits[i] == tape) tapeunits[i] = NULL; } + xfree(tape); } static void tape_init (int unit, struct scsi_data_tape *tape, const TCHAR *tape_directory, bool readonly) -- 2.47.3