ref: a426c08ce22b9f9b256ab028c223b362e2519361
parent: 23b189c2bcf2de03902ef0f18e23cf030c6d072a
author: cinap_lenrek <[email protected]>
date: Fri Jan 11 18:18:22 EST 2013
libdraw: gengetwindow() fix mistake dont zero *winp so the "screen" pointer is preserved.
--- a/sys/src/libdraw/init.c
+++ b/sys/src/libdraw/init.c
@@ -147,13 +147,6 @@
}else{
close(fd);
buf[n] = '\0';
- if(*winp != nil){
- _freeimage1(*winp);
- *winp = nil;
- freeimage((*scrp)->image);
- freescreen(*scrp);
- *scrp = nil;
- }
image = namedimage(d, buf);
if(image == 0){
/*
@@ -166,6 +159,14 @@
goto retry;
}
fprint(2, "namedimage %s failed: %r\n", buf);
+ }
+ if(*winp != nil){
+ _freeimage1(*winp);
+ freeimage((*scrp)->image);
+ freescreen(*scrp);
+ *scrp = nil;
+ }
+ if(image == 0){
*winp = nil;
d->screenimage = nil;
return -1;
@@ -176,9 +177,9 @@
d->screenimage = image;
*scrp = allocscreen(image, d->white, 0);
if(*scrp == nil){
- freeimage(d->screenimage);
*winp = nil;
d->screenimage = nil;
+ freeimage(image);
return -1;
}
@@ -189,12 +190,12 @@
if(*winp == nil){
freescreen(*scrp);
*scrp = nil;
- freeimage(image);
d->screenimage = nil;
+ freeimage(image);
return -1;
}
- d->screenimage = *winp;
assert((*winp)->chan != 0);
+ d->screenimage = *winp;
return 1;
}