mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: alsa: fix leaks in get_data_path()
Coverity rightfully complains that assigning to `path` will lose its previous value leading to resource leaks.
This commit is contained in:
parent
7465175ad0
commit
e0bfdb9f46
1 changed files with 3 additions and 4 deletions
|
|
@ -251,7 +251,6 @@ char *get_data_path(const char *data_dir, const char *data_type, const char *fna
|
||||||
};
|
};
|
||||||
const char *e;
|
const char *e;
|
||||||
spa_autofree char *base = NULL;
|
spa_autofree char *base = NULL;
|
||||||
spa_autofree char *path = NULL;
|
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
if (data_dir)
|
if (data_dir)
|
||||||
|
|
@ -271,18 +270,18 @@ char *get_data_path(const char *data_dir, const char *data_type, const char *fna
|
||||||
base = get_xdg_home("XDG_CONFIG_HOME", ".config");
|
base = get_xdg_home("XDG_CONFIG_HOME", ".config");
|
||||||
if (base) {
|
if (base) {
|
||||||
SPA_FOR_EACH_ELEMENT_VAR(subpaths, subpath) {
|
SPA_FOR_EACH_ELEMENT_VAR(subpaths, subpath) {
|
||||||
path = spa_aprintf("%s/%s/%s", base, *subpath, data_type);
|
spa_autofree char *path = spa_aprintf("%s/%s/%s", base, *subpath, data_type);
|
||||||
if ((result = try_path(fname, path)) != NULL)
|
if ((result = try_path(fname, path)) != NULL)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPA_FOR_EACH_ELEMENT_VAR(subpaths, subpath) {
|
SPA_FOR_EACH_ELEMENT_VAR(subpaths, subpath) {
|
||||||
path = spa_aprintf("/etc/%s/%s", *subpath, data_type);
|
spa_autofree char *path = spa_aprintf("/etc/%s/%s", *subpath, data_type);
|
||||||
if ((result = try_path(fname, path)) != NULL)
|
if ((result = try_path(fname, path)) != NULL)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = spa_aprintf("%s/%s", PA_ALSA_DATA_DIR, data_type);
|
spa_autofree char *path = spa_aprintf("%s/%s", PA_ALSA_DATA_DIR, data_type);
|
||||||
return pa_maybe_prefix_path(fname, path);
|
return pa_maybe_prefix_path(fname, path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue