mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	acp: handle some errors better
Handle allocation failure and size overflow.
This commit is contained in:
		
							parent
							
								
									6ee9e62787
								
							
						
					
					
						commit
						3c9bd37fa1
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
					@ -35,6 +35,7 @@ extern "C" {
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <math.h>
 | 
					#include <math.h>
 | 
				
			||||||
 | 
					#include <limits.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <spa/utils/string.h>
 | 
					#include <spa/utils/string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -660,6 +661,8 @@ static inline char *pa_readlink(const char *p) {
 | 
				
			||||||
        ssize_t n;
 | 
					        ssize_t n;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        c = pa_xmalloc(l);
 | 
					        c = pa_xmalloc(l);
 | 
				
			||||||
 | 
					        if (c == NULL)
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((n = readlink(p, c, l-1)) < 0) {
 | 
					        if ((n = readlink(p, c, l-1)) < 0) {
 | 
				
			||||||
            pa_xfree(c);
 | 
					            pa_xfree(c);
 | 
				
			||||||
| 
						 | 
					@ -672,6 +675,9 @@ static inline char *pa_readlink(const char *p) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_xfree(c);
 | 
					        pa_xfree(c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (l >= (size_t)(INT_MAX / 2))
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
        l *= 2;
 | 
					        l *= 2;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue