Fixed some Visual Studio analyze warnings
authorSam Lantinga <slouken@libsdl.org>
Sat, 15 Jun 2013 02:46:32 -0700
changeset 7332 b53acf6ab70b
parent 7308 728e5f22a82f
child 7333 b74f920d964e
Fixed some Visual Studio analyze warnings
src/audio/winmm/SDL_winmm.c
src/render/SDL_yuv_sw.c
src/video/windows/SDL_windowsclipboard.c
--- a/src/audio/winmm/SDL_winmm.c	Thu Jun 13 22:30:02 2013 -0700
+++ b/src/audio/winmm/SDL_winmm.c	Sat Jun 15 02:46:32 2013 -0700
@@ -162,16 +162,6 @@
             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 @@
             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;
     }
--- a/src/render/SDL_yuv_sw.c	Thu Jun 13 22:30:02 2013 -0700
+++ b/src/render/SDL_yuv_sw.c	Sat Jun 15 02:46:32 2013 -0700
@@ -1202,7 +1202,11 @@
         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;
 }
--- a/src/video/windows/SDL_windowsclipboard.c	Thu Jun 13 22:30:02 2013 -0700
+++ b/src/video/windows/SDL_windowsclipboard.c	Sat Jun 15 02:46:32 2013 -0700
@@ -77,15 +77,17 @@
         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)) {