# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1378403920 0 # Node ID f7d408a477526766e31505d0dcaa574525217c4d # Parent 0768bbcf67e585423f3321f296f9fe606a9c873b 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. diff -r 0768bbcf67e5 -r f7d408a47752 gtk/dw.c --- 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) { diff -r 0768bbcf67e5 -r f7d408a47752 gtk3/dw.c --- 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) { diff -r 0768bbcf67e5 -r f7d408a47752 mac/dw.m --- 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)) { diff -r 0768bbcf67e5 -r f7d408a47752 os2/dw.c --- 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) diff -r 0768bbcf67e5 -r f7d408a47752 win/dw.c --- 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)