Merge pull request #200 from jan-schreib/check_malloc
check return values of malloc and handle error.
This commit is contained in:
		
						commit
						9117df53ed
					
				
							
								
								
									
										10
									
								
								dbus.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								dbus.c
									
									
									
									
									
								
							| @ -1,10 +1,14 @@ | |||||||
| /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ | /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ | ||||||
| 
 | 
 | ||||||
|  | #include <stdlib.h> | ||||||
|  | #include <stdio.h> | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
|  | #include <string.h> | ||||||
| #include <gio/gio.h> | #include <gio/gio.h> | ||||||
| #include "dunst.h" | #include "dunst.h" | ||||||
| #include "dbus.h" | #include "dbus.h" | ||||||
| #include "notification.h" | #include "notification.h" | ||||||
|  | #include "utils.h" | ||||||
| 
 | 
 | ||||||
| GDBusConnection *dbus_conn; | GDBusConnection *dbus_conn; | ||||||
| 
 | 
 | ||||||
| @ -124,6 +128,9 @@ static void onNotify(GDBusConnection * connection, | |||||||
|         gchar *summary = NULL; |         gchar *summary = NULL; | ||||||
|         gchar *body = NULL; |         gchar *body = NULL; | ||||||
|         Actions *actions = malloc(sizeof(Actions)); |         Actions *actions = malloc(sizeof(Actions)); | ||||||
|  |         if(actions == NULL) { | ||||||
|  |                 die("Unable to allocate memory", EXIT_FAILURE); | ||||||
|  |         } | ||||||
|         gint timeout = -1; |         gint timeout = -1; | ||||||
| 
 | 
 | ||||||
|         /* hints */ |         /* hints */ | ||||||
| @ -268,6 +275,9 @@ static void onNotify(GDBusConnection * connection, | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         notification *n = malloc(sizeof(notification)); |         notification *n = malloc(sizeof(notification)); | ||||||
|  |         if(n == NULL) { | ||||||
|  |                 die("Unable to allocate memory", EXIT_FAILURE); | ||||||
|  |         } | ||||||
|         n->appname = appname; |         n->appname = appname; | ||||||
|         n->summary = summary; |         n->summary = summary; | ||||||
|         n->body = body; |         n->body = body; | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								dunst.c
									
									
									
									
									
								
							| @ -319,6 +319,9 @@ int main(int argc, char *argv[]) | |||||||
| 
 | 
 | ||||||
|         if (settings.startup_notification) { |         if (settings.startup_notification) { | ||||||
|                 notification *n = malloc(sizeof(notification)); |                 notification *n = malloc(sizeof(notification)); | ||||||
|  |                 if(n == NULL) { | ||||||
|  |                         die("Unable to allocate memory", EXIT_FAILURE); | ||||||
|  |                 } | ||||||
|                 n->appname = strdup("dunst"); |                 n->appname = strdup("dunst"); | ||||||
|                 n->summary = strdup("startup"); |                 n->summary = strdup("startup"); | ||||||
|                 n->body = strdup("dunst is up and running"); |                 n->body = strdup("dunst is up and running"); | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								x.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								x.c
									
									
									
									
									
								
							| @ -330,6 +330,9 @@ static cairo_surface_t *get_icon_surface(char *icon_path) | |||||||
| static colored_layout *r_init_shared(cairo_t *c, notification *n) | static colored_layout *r_init_shared(cairo_t *c, notification *n) | ||||||
| { | { | ||||||
|         colored_layout *cl = malloc(sizeof(colored_layout)); |         colored_layout *cl = malloc(sizeof(colored_layout)); | ||||||
|  |         if(cl == NULL) { | ||||||
|  |                 die("Unable to allocate memory", EXIT_FAILURE); | ||||||
|  |         } | ||||||
|         cl->l = pango_cairo_create_layout(c); |         cl->l = pango_cairo_create_layout(c); | ||||||
| 
 | 
 | ||||||
|         if (!settings.word_wrap) { |         if (!settings.word_wrap) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse