# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1315679665 0 # Node ID b1b23de965d7cb7f6505a3fbf3626d97478aa17c # Parent 88cc189b5e568fe5ad565acf0a35b8ba4aeee122 Fixed using a pointer after being free()ed on Windows and Mac. diff -r 88cc189b5e56 -r b1b23de965d7 mac/dw.m --- a/mac/dw.m Sat Sep 10 17:59:37 2011 +0000 +++ b/mac/dw.m Sat Sep 10 18:34:25 2011 +0000 @@ -9337,18 +9337,18 @@ NSImageView *iv; NSSize size; PMPrintSettings settings; - int x; + int x, result = DW_ERROR_UNKNOWN; UInt32 start, end; if(!p) - return DW_ERROR_UNKNOWN; + return result; /* Figure out the printer/paper size */ pi = p->pi; size = [pi paperSize]; /* Create an image view to print and a pixmap to draw into */ iv = [[NSImageView alloc] init]; - pixmap = dw_pixmap_new(iv, size.width, size.height, 8); + pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); rep = pixmap->image; /* Create an image with the data from the pixmap @@ -9367,7 +9367,7 @@ /* Get the page range */ settings = [pi PMPrintSettings]; PMGetFirstPage(settings, &start); - if(start) + if(start > 0) start--; PMGetLastPage(settings, &end); PMSetPageRange(settings, 1, 1); @@ -9386,10 +9386,12 @@ dw_color_foreground_set(DW_CLR_WHITE); dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height); } + if(p->drawfunc) + result = DW_ERROR_NONE; /* Free memory */ dw_pixmap_destroy(pixmap); free(p); - return p->drawfunc ? DW_ERROR_NONE : DW_ERROR_UNKNOWN; + return result; } /* diff -r 88cc189b5e56 -r b1b23de965d7 win/dw.c --- a/win/dw.c Sat Sep 10 17:59:37 2011 +0000 +++ b/win/dw.c Sat Sep 10 18:34:25 2011 +0000 @@ -10050,13 +10050,13 @@ { DWPrint *p = print; HPIXMAP pixmap; - int x; + int x, result = DW_ERROR_UNKNOWN; if(!p) - return DW_ERROR_UNKNOWN; + return result; if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) - return DW_ERROR_UNKNOWN; + return result; pixmap->width = GetDeviceCaps(p->pd.hDC, PHYSICALWIDTH); pixmap->height = GetDeviceCaps(p->pd.hDC, PHYSICALHEIGHT); @@ -10079,10 +10079,12 @@ EndPage(p->pd.hDC); } EndDoc(p->pd.hDC); + if(p->drawfunc) + result = DW_ERROR_NONE; /* Free memory */ dw_pixmap_destroy(pixmap); free(p); - return p->drawfunc ? DW_ERROR_NONE : DW_ERROR_UNKNOWN; + return result; } /*