mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: audioconvert: fix allocation size calculation
Currently, the code allocates sizeof(header) * sizeof(item) * n_items bytes instead of the more appropriate sizeof(header) + sizeof(item) * n_items Fix that by simply changing the first multiplication to addition, and furthermore, use a flexible array member instead of a zero-sized array. Found by clang-tidy.
This commit is contained in:
		
							parent
							
								
									6515553b7d
								
							
						
					
					
						commit
						d2114c3f2e
					
				
					 2 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -31,7 +31,7 @@
 | 
				
			||||||
struct peaks_data {
 | 
					struct peaks_data {
 | 
				
			||||||
	uint32_t o_count;
 | 
						uint32_t o_count;
 | 
				
			||||||
	uint32_t i_count;
 | 
						uint32_t i_count;
 | 
				
			||||||
	float max_f[0];
 | 
						float max_f[];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined (HAVE_SSE)
 | 
					#if defined (HAVE_SSE)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -146,7 +146,7 @@ int resample_peaks_init(struct resample *r)
 | 
				
			||||||
	r->delay = impl_peaks_delay;
 | 
						r->delay = impl_peaks_delay;
 | 
				
			||||||
	r->in_len = impl_peaks_in_len;
 | 
						r->in_len = impl_peaks_in_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d = r->data = calloc(1, sizeof(struct peaks_data) * sizeof(float) * r->channels);
 | 
						d = r->data = calloc(1, sizeof(struct peaks_data) + sizeof(float) * r->channels);
 | 
				
			||||||
	if (r->data == NULL)
 | 
						if (r->data == NULL)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue