mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	dlclose on errors
This commit is contained in:
		
							parent
							
								
									f08c35259c
								
							
						
					
					
						commit
						35bb7d794b
					
				
					 1 changed files with 13 additions and 8 deletions
				
			
		| 
						 | 
					@ -46,28 +46,33 @@ static inline struct spa_handle *load_handle(const struct spa_support *support,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((hnd = dlopen(path, RTLD_NOW)) == NULL) {
 | 
						if ((hnd = dlopen(path, RTLD_NOW)) == NULL) {
 | 
				
			||||||
		fprintf(stderr, "can't load %s: %s\n", lib, dlerror());
 | 
							fprintf(stderr, "can't load %s: %s\n", lib, dlerror());
 | 
				
			||||||
		errno = -ENOENT;
 | 
							res = -ENOENT;
 | 
				
			||||||
		return NULL;
 | 
							goto error;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
 | 
						if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
 | 
				
			||||||
		fprintf(stderr, "can't find enum function\n");
 | 
							fprintf(stderr, "can't find enum function\n");
 | 
				
			||||||
		errno = -ENOENT;
 | 
							res = -ENXIO;
 | 
				
			||||||
		return NULL;
 | 
							goto error_close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((factory = get_factory(enum_func, name, SPA_VERSION_HANDLE_FACTORY)) == NULL) {
 | 
						if ((factory = get_factory(enum_func, name, SPA_VERSION_HANDLE_FACTORY)) == NULL) {
 | 
				
			||||||
		fprintf(stderr, "can't find factory\n");
 | 
							fprintf(stderr, "can't find factory\n");
 | 
				
			||||||
		errno = -ENOENT;
 | 
							res = -ENOENT;
 | 
				
			||||||
		return NULL;
 | 
							goto error_close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
 | 
						handle = calloc(1, spa_handle_factory_get_size(factory, NULL));
 | 
				
			||||||
	if ((res = spa_handle_factory_init(factory, handle,
 | 
						if ((res = spa_handle_factory_init(factory, handle,
 | 
				
			||||||
					NULL, support, n_support)) < 0) {
 | 
										NULL, support, n_support)) < 0) {
 | 
				
			||||||
		fprintf(stderr, "can't make factory instance: %d\n", res);
 | 
							fprintf(stderr, "can't make factory instance: %d\n", res);
 | 
				
			||||||
		errno = -res;
 | 
							goto error_close;
 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return handle;
 | 
						return handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error_close:
 | 
				
			||||||
 | 
						dlclose(hnd);
 | 
				
			||||||
 | 
					error:
 | 
				
			||||||
 | 
						errno = -res;
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline uint32_t get_cpu_flags(void)
 | 
					static inline uint32_t get_cpu_flags(void)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue