mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	stream: Fix memory leak
Cleanup controls instead of inserting new elements with id 0 into the controls list every time there is an unsupported or invalid PropInfo in an info_changed node event.
This commit is contained in:
		
							parent
							
								
									9255cfbd7c
								
							
						
					
					
						commit
						aa3aa6bb05
					
				
					 1 changed files with 11 additions and 5 deletions
				
			
		| 
						 | 
					@ -1182,8 +1182,6 @@ static int node_event_param(void *object, int seq,
 | 
				
			||||||
			return -EINVAL;
 | 
								return -EINVAL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_list_append(&stream->controls, &c->link);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		pod = spa_pod_get_values(type, &n_vals, &choice);
 | 
							pod = spa_pod_get_values(type, &n_vals, &choice);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		c->type = SPA_POD_TYPE(pod);
 | 
							c->type = SPA_POD_TYPE(pod);
 | 
				
			||||||
| 
						 | 
					@ -1204,22 +1202,28 @@ static int node_event_param(void *object, int seq,
 | 
				
			||||||
			vals[0] = SPA_POD_VALUE(struct spa_pod_bool, pod);
 | 
								vals[0] = SPA_POD_VALUE(struct spa_pod_bool, pod);
 | 
				
			||||||
			n_vals = 3;
 | 
								n_vals = 3;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else {
 | 
				
			||||||
 | 
								free(c);
 | 
				
			||||||
			return -ENOTSUP;
 | 
								return -ENOTSUP;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		c->container = container != SPA_ID_INVALID ? container : c->type;
 | 
							c->container = container != SPA_ID_INVALID ? container : c->type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch (choice) {
 | 
							switch (choice) {
 | 
				
			||||||
		case SPA_CHOICE_None:
 | 
							case SPA_CHOICE_None:
 | 
				
			||||||
			if (n_vals < 1)
 | 
								if (n_vals < 1) {
 | 
				
			||||||
 | 
									free(c);
 | 
				
			||||||
				return -EINVAL;
 | 
									return -EINVAL;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			c->control.n_values = 1;
 | 
								c->control.n_values = 1;
 | 
				
			||||||
			c->control.max_values = 1;
 | 
								c->control.max_values = 1;
 | 
				
			||||||
			c->control.values[0] = c->control.def = c->control.min = c->control.max = vals[0];
 | 
								c->control.values[0] = c->control.def = c->control.min = c->control.max = vals[0];
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case SPA_CHOICE_Range:
 | 
							case SPA_CHOICE_Range:
 | 
				
			||||||
			if (n_vals < 3)
 | 
								if (n_vals < 3) {
 | 
				
			||||||
 | 
									free(c);
 | 
				
			||||||
				return -EINVAL;
 | 
									return -EINVAL;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			c->control.n_values = 1;
 | 
								c->control.n_values = 1;
 | 
				
			||||||
			c->control.max_values = 1;
 | 
								c->control.max_values = 1;
 | 
				
			||||||
			c->control.values[0] = vals[0];
 | 
								c->control.values[0] = vals[0];
 | 
				
			||||||
| 
						 | 
					@ -1228,10 +1232,12 @@ static int node_event_param(void *object, int seq,
 | 
				
			||||||
			c->control.max = vals[2];
 | 
								c->control.max = vals[2];
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
 | 
								free(c);
 | 
				
			||||||
			return -ENOTSUP;
 | 
								return -ENOTSUP;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		c->id = iid;
 | 
							c->id = iid;
 | 
				
			||||||
 | 
							spa_list_append(&stream->controls, &c->link);
 | 
				
			||||||
		pw_log_debug("%p: add control %d (%s) container:%d (def:%f min:%f max:%f)",
 | 
							pw_log_debug("%p: add control %d (%s) container:%d (def:%f min:%f max:%f)",
 | 
				
			||||||
				stream, c->id, c->control.name, c->container,
 | 
									stream, c->id, c->control.name, c->container,
 | 
				
			||||||
				c->control.def, c->control.min, c->control.max);
 | 
									c->control.def, c->control.min, c->control.max);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue