mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
rio: check the return value of malloc(3)
This commit is contained in:
parent
846f724983
commit
ffbdd1aa20
3 changed files with 14 additions and 0 deletions
|
@ -151,6 +151,11 @@ getclient(Window w, int create)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
c = (Client *)malloc(sizeof(Client));
|
c = (Client *)malloc(sizeof(Client));
|
||||||
|
if (!c){
|
||||||
|
fprintf(stderr, "rio: Failed to allocate memory\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
memset(c, 0, sizeof(Client));
|
memset(c, 0, sizeof(Client));
|
||||||
c->window = w;
|
c->window = w;
|
||||||
/* c->parent will be set by the caller */
|
/* c->parent will be set by the caller */
|
||||||
|
|
|
@ -213,6 +213,10 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
num_screens = ScreenCount(dpy);
|
num_screens = ScreenCount(dpy);
|
||||||
screens = (ScreenInfo *)malloc(sizeof(ScreenInfo) * num_screens);
|
screens = (ScreenInfo *)malloc(sizeof(ScreenInfo) * num_screens);
|
||||||
|
if (!screens){
|
||||||
|
fprintf(stderr, "rio: Failed to allocate memory\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < num_screens; i++)
|
for(i = 0; i < num_screens; i++)
|
||||||
initscreen(&screens[i], i, background);
|
initscreen(&screens[i], i, background);
|
||||||
|
|
|
@ -320,6 +320,11 @@ getcmaps(Client *c)
|
||||||
c->cmapwins = cw;
|
c->cmapwins = cw;
|
||||||
|
|
||||||
c->wmcmaps = (Colormap*)malloc(n*sizeof(Colormap));
|
c->wmcmaps = (Colormap*)malloc(n*sizeof(Colormap));
|
||||||
|
if (!c->wmcmaps){
|
||||||
|
fprintf(stderr, "rio: Failed to allocate memory\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < n; i++){
|
for(i = 0; i < n; i++){
|
||||||
if(cw[i] == c->window)
|
if(cw[i] == c->window)
|
||||||
c->wmcmaps[i] = c->cmap;
|
c->wmcmaps[i] = c->cmap;
|
||||||
|
|
Loading…
Reference in a new issue