mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	stream: add some redundant checks
Remove some redundant checks and handle calloc failure.
This commit is contained in:
		
							parent
							
								
									95fb03c8e3
								
							
						
					
					
						commit
						a60eb4fe64
					
				
					 1 changed files with 5 additions and 9 deletions
				
			
		| 
						 | 
					@ -1270,6 +1270,9 @@ static int node_event_param(void *object, int seq,
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		c = calloc(1, sizeof(*c) + SPA_POD_SIZE(param));
 | 
							c = calloc(1, sizeof(*c) + SPA_POD_SIZE(param));
 | 
				
			||||||
 | 
							if (c == NULL)
 | 
				
			||||||
 | 
								return -errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		c->info = SPA_PTROFF(c, sizeof(*c), struct spa_pod);
 | 
							c->info = SPA_PTROFF(c, sizeof(*c), struct spa_pod);
 | 
				
			||||||
		memcpy(c->info, param, SPA_POD_SIZE(param));
 | 
							memcpy(c->info, param, SPA_POD_SIZE(param));
 | 
				
			||||||
		c->control.n_values = 0;
 | 
							c->control.n_values = 0;
 | 
				
			||||||
| 
						 | 
					@ -1286,7 +1289,7 @@ static int node_event_param(void *object, int seq,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pod = spa_pod_get_values(type, &n_vals, &choice);
 | 
							pod = spa_pod_get_values(type, &n_vals, &choice);
 | 
				
			||||||
		if (n_vals == 0) {
 | 
							if (n_vals < 1) {
 | 
				
			||||||
			free(c);
 | 
								free(c);
 | 
				
			||||||
			return -EINVAL;
 | 
								return -EINVAL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -1318,19 +1321,12 @@ static int node_event_param(void *object, int seq,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch (choice) {
 | 
							switch (choice) {
 | 
				
			||||||
		case SPA_CHOICE_None:
 | 
							case SPA_CHOICE_None:
 | 
				
			||||||
			if (n_vals < 1) {
 | 
					 | 
				
			||||||
				free(c);
 | 
					 | 
				
			||||||
				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) {
 | 
							case SPA_CHOICE_Step:
 | 
				
			||||||
				free(c);
 | 
					 | 
				
			||||||
				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];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue