Commit Diff


commit - 846f724983f098541df0d6f44b1a617b60602aa2
commit + ffbdd1aa20c8a20a8e9dcd3cec644b6dfa3c6acb
blob - 256261cad639ee78aaac4348c2ca83c80a8232ae
blob + d78be62614a7389d749b53350ad3500687f4e5e2
--- src/cmd/rio/client.c
+++ src/cmd/rio/client.c
@@ -151,6 +151,11 @@ getclient(Window w, int create)
 		return 0;
 
 	c = (Client *)malloc(sizeof(Client));
+	if (!c){
+		fprintf(stderr, "rio: Failed to allocate memory\n");
+		exit(1);
+	}
+
 	memset(c, 0, sizeof(Client));
 	c->window = w;
 	/* c->parent will be set by the caller */
blob - 1e0b3797152589c1e5198d766e93688a224de58f
blob + 09c1316e132e16175c0efca47480beeab44db24c
--- src/cmd/rio/main.c
+++ src/cmd/rio/main.c
@@ -213,6 +213,10 @@ main(int argc, char *argv[])
 
 	num_screens = ScreenCount(dpy);
 	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++)
 		initscreen(&screens[i], i, background);
blob - b068a101de251ed23379d961d322d284d4d2e00a
blob + 07c9d47984725203dc344838b5af4e1bdab9742b
--- src/cmd/rio/manage.c
+++ src/cmd/rio/manage.c
@@ -320,6 +320,11 @@ getcmaps(Client *c)
 	c->cmapwins = cw;
 
 	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++){
 		if(cw[i] == c->window)
 			c->wmcmaps[i] = c->cmap;