mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	client: fix a strdup memory leak
Memory leak found by valgrinding simple-shm client. struct wl_global::interface is a strdup()'d string that was never freed. Make a function for freeing a wl_global, and use it. krh: Edit to name wl_global destructor wl_global_destroy. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
		
							parent
							
								
									58bb064afa
								
							
						
					
					
						commit
						e631ab6cde
					
				
					 1 changed files with 10 additions and 3 deletions
				
			
		| 
						 | 
					@ -251,6 +251,14 @@ display_handle_global(void *data,
 | 
				
			||||||
				     id, interface, version, listener->data);
 | 
									     id, interface, version, listener->data);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					wl_global_destroy(struct wl_global *global)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						wl_list_remove(&global->link);
 | 
				
			||||||
 | 
						free(global->interface);
 | 
				
			||||||
 | 
						free(global);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
display_handle_global_remove(void *data,
 | 
					display_handle_global_remove(void *data,
 | 
				
			||||||
                             struct wl_display *display, uint32_t id)
 | 
					                             struct wl_display *display, uint32_t id)
 | 
				
			||||||
| 
						 | 
					@ -259,8 +267,7 @@ display_handle_global_remove(void *data,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_for_each(global, &display->global_list, link)
 | 
						wl_list_for_each(global, &display->global_list, link)
 | 
				
			||||||
		if (global->id == id) {
 | 
							if (global->id == id) {
 | 
				
			||||||
			wl_list_remove(&global->link);
 | 
								wl_global_destroy(global);
 | 
				
			||||||
			free(global);
 | 
					 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -394,7 +401,7 @@ wl_display_destroy(struct wl_display *display)
 | 
				
			||||||
	wl_map_release(&display->objects);
 | 
						wl_map_release(&display->objects);
 | 
				
			||||||
	wl_list_for_each_safe(global, gnext,
 | 
						wl_list_for_each_safe(global, gnext,
 | 
				
			||||||
			      &display->global_list, link)
 | 
								      &display->global_list, link)
 | 
				
			||||||
		free(global);
 | 
							wl_global_destroy(global);
 | 
				
			||||||
	wl_list_for_each_safe(listener, lnext,
 | 
						wl_list_for_each_safe(listener, lnext,
 | 
				
			||||||
			      &display->global_listener_list, link)
 | 
								      &display->global_listener_list, link)
 | 
				
			||||||
		free(listener);
 | 
							free(listener);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue