Mercurial > dwindows
changeset 1143:b1b23de965d7
Fixed using a pointer after being free()ed on Windows and Mac.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 10 Sep 2011 18:34:25 +0000 |
parents | 88cc189b5e56 |
children | 5878dbfafbe2 |
files | mac/dw.m win/dw.c |
diffstat | 2 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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; } /*
--- 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; } /*