changeset 1886:f7d408a47752

Fix a couple of errors reported by the static analyzer on Mac.... Also added similar fixes to the other platforms as well just in case.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 05 Sep 2013 17:58:40 +0000
parents 0768bbcf67e5
children 09860ba329a4
files gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c win/dw.c
diffstat 5 files changed, 40 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Fri Aug 30 00:07:22 2013 +0000
+++ b/gtk/dw.c	Thu Sep 05 17:58:40 2013 +0000
@@ -2391,6 +2391,9 @@
 {
    void *tmp;
    int newprocess = 0;
+   
+   if(!dialog)
+      return NULL;
 
    /* _dw_thread will be -1 if dw_main hasn't been run yet. */
    if(_dw_thread == (pthread_t)-1)
@@ -9813,12 +9816,15 @@
       }
 
       if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
+      {
+         free(array);
          return;
+      }
 
       if(FD_ISSET(listenfd, &rd))
       {
          struct _seminfo *newarray;
-            int newfd = accept(listenfd, 0, 0);
+         int newfd = accept(listenfd, 0, 0);
 
          if(newfd > -1)
          {
--- a/gtk3/dw.c	Fri Aug 30 00:07:22 2013 +0000
+++ b/gtk3/dw.c	Thu Sep 05 17:58:40 2013 +0000
@@ -2058,6 +2058,9 @@
    void *tmp;
    int newprocess = 0;
 
+   if(!dialog)
+      return NULL;
+
    /* _dw_thread will be -1 if dw_main hasn't been run yet. */
    if(_dw_thread == (pthread_t)-1)
    {
@@ -8032,12 +8035,15 @@
       }
 
       if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
+      {
+         free(array);
          return;
+      }
 
       if(FD_ISSET(listenfd, &rd))
       {
          struct _seminfo *newarray;
-            int newfd = accept(listenfd, 0, 0);
+         int newfd = accept(listenfd, 0, 0);
 
          if(newfd > -1)
          {
--- a/mac/dw.m	Fri Aug 30 00:07:22 2013 +0000
+++ b/mac/dw.m	Thu Sep 05 17:58:40 2013 +0000
@@ -3694,15 +3694,18 @@
  */
 void * API dw_dialog_wait(DWDialog *dialog)
 {
-    void *tmp;
-
-    while(!dialog->done)
-    {
-        _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]);
-    }
-    dw_event_close(&dialog->eve);
-    tmp = dialog->result;
-    free(dialog);
+    void *tmp = NULL;
+
+    if(dialog)
+    {
+        while(!dialog->done)
+        {
+            _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]);
+        }
+        dw_event_close(&dialog->eve);
+        tmp = dialog->result;
+        free(dialog);
+    }
     return tmp;
 }
 
@@ -7836,12 +7839,10 @@
  */
 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
 {
-    DWBitBlt *bltinfo = calloc(1, sizeof(DWBitBlt));
+    DWBitBlt *bltinfo;
     NSValue* bi;
     DW_LOCAL_POOL_IN;
 
-    bi = [NSValue valueWithPointer:bltinfo];
-
     /* Sanity checks */
     if((!dest && !destp) || (!src && !srcp) ||
        ((srcwidth == -1 || srcheight == -1) && srcwidth != srcheight))
@@ -7850,6 +7851,9 @@
         return DW_ERROR_GENERAL;
     }
 
+    bltinfo = calloc(1, sizeof(DWBitBlt));
+    bi = [NSValue valueWithPointer:bltinfo];
+    
     /* Fill in the information */
     bltinfo->dest = dest;
     bltinfo->src = src;
@@ -10583,7 +10587,10 @@
       }
 
       if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
-         return;
+      {
+          free(array);
+          return;
+      }
 
       if(FD_ISSET(listenfd, &rd))
       {
--- a/os2/dw.c	Fri Aug 30 00:07:22 2013 +0000
+++ b/os2/dw.c	Thu Sep 05 17:58:40 2013 +0000
@@ -4637,6 +4637,9 @@
    QMSG qmsg;
    void *tmp;
 
+   if(!dialog)
+      return NULL;
+
    while (WinGetMsg(dwhab, &qmsg, 0, 0, 0))
    {
       if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
--- a/win/dw.c	Fri Aug 30 00:07:22 2013 +0000
+++ b/win/dw.c	Thu Sep 05 17:58:40 2013 +0000
@@ -4153,6 +4153,9 @@
    MSG msg;
    void *tmp;
 
+   if(!dialog)
+      return NULL;
+
    while (GetMessage(&msg,NULL,0,0))
    {
       if(msg.hwnd == NULL && msg.message == WM_TIMER)