# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1341129085 0 # Node ID 47e503ecc8124aabb64d36f72973461ea98eb624 # Parent 15414cbe857f29ead260cf2e629b7e9a8fab042f Ported clang/Xcode fixes to Windows and OS/2 just in case. diff -r 15414cbe857f -r 47e503ecc812 os2/dw.c --- a/os2/dw.c Sat Jun 30 19:53:18 2012 +0000 +++ b/os2/dw.c Sun Jul 01 07:51:25 2012 +0000 @@ -7710,12 +7710,14 @@ HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box"); /* Do some sanity bounds checking */ + if(!thisitem) + thisbox->count = 0; if(index < 0) index = 0; if(index > thisbox->count) index = thisbox->count; - tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + tmpitem = calloc(sizeof(Item), (thisbox->count+1)); for(z=0;zcount;z++) { @@ -7725,7 +7727,6 @@ x++; } - WinQueryClassName(item, 99, (PCH)tmpbuf); if(vsize && !height) @@ -7758,7 +7759,7 @@ thisbox->items = tmpitem; - if(thisbox->count) + if(thisitem) free(thisitem); thisbox->count++; @@ -7798,8 +7799,11 @@ if(thisbox && thisbox->count) { int z, index = -1; - Item *tmpitem, *thisitem = thisbox->items; - + Item *tmpitem = NULL, *thisitem = thisbox->items; + + if(!thisitem) + thisbox->count = 0; + for(z=0;zcount;z++) { if(thisitem[z].hwnd == handle) @@ -7809,21 +7813,29 @@ if(index == -1) return DW_ERROR_GENERAL; - tmpitem = malloc(sizeof(Item)*(thisbox->count-1)); - - /* Copy all but the current entry to the new list */ - for(z=0;zcount;z++) - { - tmpitem[z-1] = thisitem[z]; + if(thisbox->count > 1) + { + tmpitem = calloc(sizeof(Item), (thisbox->count-1)); + + /* Copy all but the current entry to the new list */ + for(z=0;zcount;z++) + { + tmpitem[z-1] = thisitem[z]; + } } thisbox->items = tmpitem; - free(thisitem); - thisbox->count--; + if(thisitem) + free(thisitem); + if(tmpitem) + thisbox->count--; + else + thisbox->count = 0; + /* If it isn't padding, reset the parent */ if(handle) WinSetParent(handle, HWND_OBJECT, FALSE); @@ -7851,24 +7863,32 @@ if(thisbox && index > -1 && index < thisbox->count) { int z; - Item *tmpitem, *thisitem = thisbox->items; + Item *tmpitem = NULL, *thisitem = thisbox->items; HWND handle = thisitem[index].hwnd; - tmpitem = malloc(sizeof(Item)*(thisbox->count-1)); - - /* Copy all but the current entry to the new list */ - for(z=0;zcount;z++) - { - tmpitem[z-1] = thisitem[z]; + if(thisbox->count > 1) + { + tmpitem = calloc(sizeof(Item), (thisbox->count-1)); + + /* Copy all but the current entry to the new list */ + for(z=0;zcount;z++) + { + tmpitem[z-1] = thisitem[z]; + } } thisbox->items = tmpitem; - free(thisitem); - thisbox->count--; + if(thisitem) + free(thisitem); + if(tmpitem) + thisbox->count--; + else + thisbox->count = 0; + /* If it isn't padding, reset the parent */ if(handle) WinSetParent(handle, HWND_OBJECT, FALSE); diff -r 15414cbe857f -r 47e503ecc812 win/dw.c --- a/win/dw.c Sat Jun 30 19:53:18 2012 +0000 +++ b/win/dw.c Sun Jul 01 07:51:25 2012 +0000 @@ -7086,12 +7086,14 @@ Item *tmpitem, *thisitem = thisbox->items; /* Do some sanity bounds checking */ + if(!thisitem) + thisbox->count = 0; if(index < 0) index = 0; if(index > thisbox->count) index = thisbox->count; - tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + tmpitem = calloc(sizeof(Item), (thisbox->count+1)); for(z=0;zcount;z++) { @@ -7144,7 +7146,7 @@ thisbox->items = tmpitem; - if(thisbox->count) + if(thisitem) free(thisitem); thisbox->count++; @@ -7199,7 +7201,10 @@ if(thisbox && thisbox->count) { int z, index = -1; - Item *tmpitem, *thisitem = thisbox->items; + Item *tmpitem = NULL, *thisitem = thisbox->items; + + if(!thisitem) + thisbox->count = 0; for(z=0;zcount;z++) { @@ -7210,21 +7215,29 @@ if(index == -1) return DW_ERROR_GENERAL; - tmpitem = malloc(sizeof(Item)*(thisbox->count-1)); - - /* Copy all but the current entry to the new list */ - for(z=0;zcount;z++) - { - tmpitem[z-1] = thisitem[z]; + if(thisbox->count > 1) + { + tmpitem = calloc(sizeof(Item), (thisbox->count-1)); + + /* Copy all but the current entry to the new list */ + for(z=0;zcount;z++) + { + tmpitem[z-1] = thisitem[z]; + } } thisbox->items = tmpitem; - free(thisitem); - thisbox->count--; + if(thisitem) + free(thisitem); + if(tmpitem) + thisbox->count--; + else + thisbox->count = 0; + SetParent(handle, DW_HWND_OBJECT); /* Queue a redraw on the top-level window */ _dw_redraw(_toplevel_window(parent), TRUE); @@ -7250,24 +7263,32 @@ if(thisbox && index > -1 && index < thisbox->count) { int z; - Item *tmpitem, *thisitem = thisbox->items; + Item *tmpitem = NULL, *thisitem = thisbox->items; HWND handle = thisitem[index].hwnd; - tmpitem = malloc(sizeof(Item)*(thisbox->count-1)); - - /* Copy all but the current entry to the new list */ - for(z=0;zcount;z++) - { - tmpitem[z-1] = thisitem[z]; + if(thisbox->count > 1) + { + tmpitem = calloc(sizeof(Item), (thisbox->count-1)); + + /* Copy all but the current entry to the new list */ + for(z=0;zcount;z++) + { + tmpitem[z-1] = thisitem[z]; + } } thisbox->items = tmpitem; - free(thisitem); - thisbox->count--; + if(thisitem) + free(thisitem); + if(tmpitem) + thisbox->count--; + else + thisbox->count = 0; + /* If it isn't padding, reset the parent */ if(handle) SetParent(handle, DW_HWND_OBJECT);