Skip to content

Fix SIGSEGV when --null is empty or whitespace-only - #270

Merged
okbob merged 1 commit into
okbob:masterfrom
vulragrag-star:fix/null-empty-optarg-segfault
Sep 21, 2026
Merged

okbob merged 1 commit into
okbob:masterfrom
vulragrag-star:fix/null-empty-optarg-segfault

Conversation

@vulragrag-star

Copy link
Copy Markdown
Contributor

Fix for issue #269.

--null with an empty or whitespace-only value makes trim_quoted_str() return NULL, and sstrndup() then crashes. Guard that case the same way config.c already does (str ? sstrndup(...) : ...) and store an empty nullstr instead.

# before: SIGSEGV
printf 'a\tb\n1\t\n' | ./pspg --tsv --null='' -X

# after: renders table, exit 0
printf 'a\tb\n1\t\n' | ./pspg --tsv --null='' -X
printf 'a\tb\n1\t\n' | ./pspg --tsv --null='   ' -X
./pspg --null='' </dev/null   # "No data", no crash

Also rebuilt with ./configure && make (same as the Linux workflow).

trim_quoted_str() returns NULL for empty/whitespace-only values;
guard before sstrndup like config.c already does.

Fixes: okbob#269
@okbob
okbob merged commit 6726d96 into okbob:master Sep 21, 2026
@okbob

okbob commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Merged, thank you for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants