mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	ipc-server: fix double-free on send error in ipc_send_event
ipc_send_reply already does client disconnect on error, so we shouldn't do it again. We also need to process current index again as disconnect removes client from the list we currently are processing (this is an indexed "list") Found through static analysis.
This commit is contained in:
		
							parent
							
								
									9c8fb7d025
								
							
						
					
					
						commit
						546ddbcd5b
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -263,7 +263,10 @@ static void ipc_send_event(const char *json_string, enum ipc_command_type event)
 | 
				
			||||||
		client->current_command = event;
 | 
							client->current_command = event;
 | 
				
			||||||
		if (!ipc_send_reply(client, json_string, (uint32_t) strlen(json_string))) {
 | 
							if (!ipc_send_reply(client, json_string, (uint32_t) strlen(json_string))) {
 | 
				
			||||||
			wlr_log_errno(L_INFO, "Unable to send reply to IPC client");
 | 
								wlr_log_errno(L_INFO, "Unable to send reply to IPC client");
 | 
				
			||||||
			ipc_client_disconnect(client);
 | 
								/* ipc_send_reply destroys client on error, which also
 | 
				
			||||||
 | 
								 * removes it from the list, so we need to process
 | 
				
			||||||
 | 
								 * current index again */
 | 
				
			||||||
 | 
								i--;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue