mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	Merge pull request #1565 from Emantor/fix/realloc_allocation
backend/drm: fix memory leak in realloc crtcs
This commit is contained in:
		
						commit
						132290aeb4
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -888,8 +888,9 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
 | 
					static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
 | 
				
			||||||
	size_t num_outputs = wl_list_length(&drm->outputs);
 | 
						size_t num_outputs = wl_list_length(&drm->outputs);
 | 
				
			||||||
 | 
						bool changed_local = changed_outputs ? false : true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (changed_outputs == NULL) {
 | 
						if (changed_local) {
 | 
				
			||||||
		changed_outputs = calloc(num_outputs, sizeof(bool));
 | 
							changed_outputs = calloc(num_outputs, sizeof(bool));
 | 
				
			||||||
		if (changed_outputs == NULL) {
 | 
							if (changed_outputs == NULL) {
 | 
				
			||||||
			wlr_log(WLR_ERROR, "Allocation failed");
 | 
								wlr_log(WLR_ERROR, "Allocation failed");
 | 
				
			||||||
| 
						 | 
					@ -952,7 +953,7 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
 | 
				
			||||||
				connectors[crtc[i]]->desired_enabled) {
 | 
									connectors[crtc[i]]->desired_enabled) {
 | 
				
			||||||
			wlr_log(WLR_DEBUG, "Could not match a CRTC for connected output %d",
 | 
								wlr_log(WLR_DEBUG, "Could not match a CRTC for connected output %d",
 | 
				
			||||||
				crtc[i]);
 | 
									crtc[i]);
 | 
				
			||||||
			return;
 | 
								goto free_changed_outputs;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1021,6 +1022,11 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		wlr_output_damage_whole(&conn->output);
 | 
							wlr_output_damage_whole(&conn->output);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					free_changed_outputs:
 | 
				
			||||||
 | 
						if (changed_local) {
 | 
				
			||||||
 | 
							free(changed_outputs);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static uint32_t get_possible_crtcs(int fd, drmModeRes *res,
 | 
					static uint32_t get_possible_crtcs(int fd, drmModeRes *res,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue