From 78fc90623d1c69275e173297fe54f614f34c1d46 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 15 Jun 2013 02:46:32 -0700 Subject: [PATCH] Fixed some Visual Studio analyze warnings --- src/audio/winmm/SDL_winmm.c | 20 ++++++++++---------- src/render/SDL_yuv_sw.c | 6 +++++- src/video/windows/SDL_windowsclipboard.c | 16 +++++++++------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index f52a3afb1..00a6245ad 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -162,16 +162,6 @@ WINMM_CloseDevice(_THIS) this->hidden->audio_sem = 0; } - if (this->hidden->hin) { - waveInClose(this->hidden->hin); - this->hidden->hin = 0; - } - - if (this->hidden->hout) { - waveOutClose(this->hidden->hout); - this->hidden->hout = 0; - } - /* Clean up mixing buffers */ for (i = 0; i < NUM_BUFFERS; ++i) { if (this->hidden->wavebuf[i].dwUser != 0xFFFF) { @@ -188,6 +178,16 @@ WINMM_CloseDevice(_THIS) this->hidden->mixbuf = NULL; } + if (this->hidden->hin) { + waveInClose(this->hidden->hin); + this->hidden->hin = 0; + } + + if (this->hidden->hout) { + waveOutClose(this->hidden->hout); + this->hidden->hout = 0; + } + SDL_free(this->hidden); this->hidden = NULL; } diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 1d7e024c2..3319fe4c2 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1202,7 +1202,11 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, break; } - *pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2; + if (rect) { + *pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2; + } else { + *pixels = swdata->planes[0]; + } *pitch = swdata->pitches[0]; return 0; } diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 83bf0caa3..3d1db4a41 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -77,15 +77,17 @@ WIN_SetClipboardText(_THIS, const char *text) hMem = GlobalAlloc(GMEM_MOVEABLE, size); if (hMem) { LPTSTR dst = (LPTSTR)GlobalLock(hMem); - /* Copy the text over, adding carriage returns as necessary */ - for (i = 0; tstr[i]; ++i) { - if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { - *dst++ = '\r'; + if (dst) { + /* Copy the text over, adding carriage returns as necessary */ + for (i = 0; tstr[i]; ++i) { + if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { + *dst++ = '\r'; + } + *dst++ = tstr[i]; } - *dst++ = tstr[i]; + *dst = 0; + GlobalUnlock(hMem); } - *dst = 0; - GlobalUnlock(hMem); EmptyClipboard(); if (!SetClipboardData(TEXT_FORMAT, hMem)) {