Fix memory leaks
This commit is contained in:
		
							parent
							
								
									f8e1e330b2
								
							
						
					
					
						commit
						61ce42a7e2
					
				
							
								
								
									
										1
									
								
								dbus.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								dbus.c
									
									
									
									
									
								
							| @ -294,6 +294,7 @@ static void onNotify(GDBusConnection * connection, | ||||
|                 n->actions = actions; | ||||
|         } else { | ||||
|                 n->actions = NULL; | ||||
|                 g_strfreev(actions->actions); | ||||
|                 free(actions); | ||||
|         } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										8
									
								
								menu.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								menu.c
									
									
									
									
									
								
							| @ -190,10 +190,12 @@ void context_menu(void) | ||||
|         int parent_io[2]; | ||||
|         if (pipe(child_io) != 0) { | ||||
|                 PERR("pipe()", errno); | ||||
|                 free(dmenu_input); | ||||
|                 return; | ||||
|         } | ||||
|         if (pipe(parent_io) != 0) { | ||||
|                 PERR("pipe()", errno); | ||||
|                 free(dmenu_input); | ||||
|                 return; | ||||
|         } | ||||
|         int pid = fork(); | ||||
| @ -222,8 +224,10 @@ void context_menu(void) | ||||
|                 close(child_io[1]); | ||||
| 
 | ||||
|                 size_t len = read(parent_io[0], buf, 1023); | ||||
|                 if (len == 0) | ||||
|                 if (len == 0) { | ||||
|                         free(dmenu_input); | ||||
|                         return; | ||||
|                 } | ||||
| 
 | ||||
|                 int status; | ||||
|                 waitpid(pid, &status, 0); | ||||
| @ -232,5 +236,7 @@ void context_menu(void) | ||||
|         close(parent_io[0]); | ||||
| 
 | ||||
|         dispatch_menu_result(buf); | ||||
| 
 | ||||
|         free(dmenu_input); | ||||
| } | ||||
| /* vim: set ts=8 sw=8 tw=0: */ | ||||
|  | ||||
| @ -155,6 +155,12 @@ void notification_free(notification * n) | ||||
|         free(n->icon); | ||||
|         free(n->msg); | ||||
|         free(n->dbus_client); | ||||
| 
 | ||||
|         if (n->actions) { | ||||
|                 g_strfreev(n->actions->actions); | ||||
|                 free(n->actions->dmenu_str); | ||||
|         } | ||||
| 
 | ||||
|         free(n); | ||||
| } | ||||
| 
 | ||||
| @ -480,11 +486,11 @@ int notification_init(notification * n, int id) | ||||
|                         string_replace_char('[', '(', human_readable); // kill square brackets
 | ||||
|                         string_replace_char(']', ')', human_readable); | ||||
| 
 | ||||
|                         n->actions->dmenu_str = | ||||
|                             string_append(n->actions->dmenu_str, | ||||
|                                           g_strdup_printf("#%s [%s]", human_readable, | ||||
|                                                                       n->appname), | ||||
|                                           "\n"); | ||||
|                         char *act_str = g_strdup_printf("#%s [%s]", human_readable, n->appname); | ||||
|                         if (act_str) { | ||||
|                                 n->actions->dmenu_str = string_append(n->actions->dmenu_str, act_str, "\n"); | ||||
|                                 free(act_str); | ||||
|                         } | ||||
|                 } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -47,8 +47,9 @@ static int ini_get_urgency(char *section, char *key, int def) | ||||
|                         fprintf(stderr, | ||||
|                                 "unknown urgency: %s, ignoring\n", | ||||
|                                 urg); | ||||
|                 free(urg); | ||||
|         } | ||||
|         if (urg) | ||||
|                 free(urg); | ||||
|         return ret; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Justin Jacobs
						Justin Jacobs