Skip to content

Commit

Permalink
Merge pull request #21 from Maksym-L/fix-segfalt-7
Browse files Browse the repository at this point in the history
Safe handling of ignoredSourceOutputs array
  • Loading branch information
ErikReider authored Aug 20, 2024
2 parents 8ac8608 + 47e8150 commit 7a70ef1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
bool printSource = false;
bool printSink = false;

char* ignoredSourceOutputs[MAX_IGNORED_SOURCE_OUTPUTS];
char* ignoredSourceOutputs[MAX_IGNORED_SOURCE_OUTPUTS] = {nullptr};
int ignoredSourceOutputsCount = 0;

if (argc > 1) {
Expand Down
13 changes: 9 additions & 4 deletions src/pulse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ void Pulse::source_output_info_callback(pa_context *,
if (i && i->proplist) {
const char *appName = pa_proplist_gets(i->proplist, "application.name");
if (appName) {
int i = 0;
while (data->ignoredSourceOutputs[i] != nullptr) {
if (strcmp(appName, data->ignoredSourceOutputs[i]) == 0) {
int ignoredSourceOutputsCount = 0;
while (
data->ignoredSourceOutputs[ignoredSourceOutputsCount] != nullptr
&& ignoreSourceOutput == false
&& ignoredSourceOutputsCount < MAX_IGNORED_SOURCE_OUTPUTS
) {
if (strcmp(appName, data->ignoredSourceOutputs[ignoredSourceOutputsCount]) == 0) {
ignoreSourceOutput = true;
break;
}
i++;
ignoredSourceOutputsCount++;
}
}
}
Expand Down

0 comments on commit 7a70ef1

Please sign in to comment.