[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] cli: Fix crash when using .include with an empty directory
PulseAudio Marge Bot
gitlab at gitlab.freedesktop.org
Fri Jan 8 00:09:31 UTC 2021
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
b1bdd27a by Patrick Gaskin at 2021-01-08T00:03:52+00:00
cli: Fix crash when using .include with an empty directory
This would previously fail the size > 0 assertion in pa_xmalloc.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/454>
- - - - -
1 changed file:
- src/pulsecore/cli-command.c
Changes:
=====================================
src/pulsecore/cli-command.c
=====================================
@@ -2118,34 +2118,34 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
}
closedir(d);
-
- count = pa_dynarray_size(files);
- sorted_files = pa_xnew(char*, count);
- for (i = 0; i < count; ++i)
- sorted_files[i] = pa_dynarray_get(files, i);
- pa_dynarray_free(files);
-
- for (i = 0; i < count; ++i) {
- for (unsigned j = 0; j < count; ++j) {
- if (strcmp(sorted_files[i], sorted_files[j]) < 0) {
- char *tmp = sorted_files[i];
- sorted_files[i] = sorted_files[j];
- sorted_files[j] = tmp;
+ if ((count = pa_dynarray_size(files))) {
+ sorted_files = pa_xnew(char*, count);
+ for (i = 0; i < count; ++i)
+ sorted_files[i] = pa_dynarray_get(files, i);
+ pa_dynarray_free(files);
+
+ for (i = 0; i < count; ++i) {
+ for (unsigned j = 0; j < count; ++j) {
+ if (strcmp(sorted_files[i], sorted_files[j]) < 0) {
+ char *tmp = sorted_files[i];
+ sorted_files[i] = sorted_files[j];
+ sorted_files[j] = tmp;
+ }
}
}
- }
- for (i = 0; i < count; ++i) {
- if (!failed) {
- if (pa_cli_command_execute_file(c, sorted_files[i], buf, fail) < 0 && *fail)
- failed = true;
- }
+ for (i = 0; i < count; ++i) {
+ if (!failed) {
+ if (pa_cli_command_execute_file(c, sorted_files[i], buf, fail) < 0 && *fail)
+ failed = true;
+ }
- pa_xfree(sorted_files[i]);
+ pa_xfree(sorted_files[i]);
+ }
+ pa_xfree(sorted_files);
+ if (failed)
+ return -1;
}
- pa_xfree(sorted_files);
- if (failed)
- return -1;
}
} else if (pa_cli_command_execute_file(c, filename, buf, fail) < 0 && *fail) {
return -1;
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/b1bdd27a6c7828ed4c055986b89fb17e90e02c2a
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/b1bdd27a6c7828ed4c055986b89fb17e90e02c2a
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210108/ee9466b5/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list