libdraw: fix allocscreen() memory leak with too many retries (from 9atom)
This commit is contained in:
parent
5bb8203bf6
commit
82b243b5ad
1 changed files with 7 additions and 6 deletions
|
@ -22,14 +22,11 @@ allocscreen(Image *image, Image *fill, int public)
|
||||||
s = malloc(sizeof(Screen));
|
s = malloc(sizeof(Screen));
|
||||||
if(s == 0)
|
if(s == 0)
|
||||||
return 0;
|
return 0;
|
||||||
SET(id);
|
|
||||||
for(try=0; try<25; try++){
|
for(try=0; try<25; try++){
|
||||||
/* loop until find a free id */
|
/* loop until find a free id */
|
||||||
a = bufimage(d, 1+4+4+4+1);
|
a = bufimage(d, 1+4+4+4+1);
|
||||||
if(a == 0){
|
if(a == 0)
|
||||||
free(s);
|
break;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
id = ++screenid;
|
id = ++screenid;
|
||||||
a[0] = 'A';
|
a[0] = 'A';
|
||||||
BPLONG(a+1, id);
|
BPLONG(a+1, id);
|
||||||
|
@ -37,8 +34,12 @@ allocscreen(Image *image, Image *fill, int public)
|
||||||
BPLONG(a+9, fill->id);
|
BPLONG(a+9, fill->id);
|
||||||
a[13] = public;
|
a[13] = public;
|
||||||
if(flushimage(d, 0) != -1)
|
if(flushimage(d, 0) != -1)
|
||||||
break;
|
goto Found;
|
||||||
}
|
}
|
||||||
|
free(s);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Found:
|
||||||
s->display = d;
|
s->display = d;
|
||||||
s->id = id;
|
s->id = id;
|
||||||
s->image = image;
|
s->image = image;
|
||||||
|
|
Loading…
Reference in a new issue