mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-14 19:41:33 +01:00
BUG/MEDIUM: deviceatlas: fix resource leaks on init error paths
When da_atlas_compile() or da_atlas_open() failed in init_deviceatlas(), atlasimgptr was leaked and da_fini() was never called. Also add a NULL check on strdup() for the default cookie name with proper cleanup of the atlas and image pointer on failure. This should be backported to lower branches.
This commit is contained in:
parent
6342705cee
commit
d8f219b380
@ -190,6 +190,8 @@ static int init_deviceatlas(void)
|
||||
if (status != DA_OK) {
|
||||
ha_alert("deviceatlas : '%s' json file is invalid.\n",
|
||||
global_deviceatlas.jsonpath);
|
||||
free(global_deviceatlas.atlasimgptr);
|
||||
da_fini();
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
@ -199,6 +201,8 @@ static int init_deviceatlas(void)
|
||||
|
||||
if (status != DA_OK) {
|
||||
ha_alert("deviceatlas : data could not be compiled.\n");
|
||||
free(global_deviceatlas.atlasimgptr);
|
||||
da_fini();
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
@ -207,6 +211,14 @@ static int init_deviceatlas(void)
|
||||
|
||||
if (global_deviceatlas.cookiename == 0) {
|
||||
global_deviceatlas.cookiename = strdup(DA_COOKIENAME_DEFAULT);
|
||||
if (unlikely(global_deviceatlas.cookiename == NULL)) {
|
||||
ha_alert("deviceatlas : out of memory.\n");
|
||||
da_atlas_close(&global_deviceatlas.atlas);
|
||||
free(global_deviceatlas.atlasimgptr);
|
||||
da_fini();
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
global_deviceatlas.cookienamelen = strlen(global_deviceatlas.cookiename);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user