Skip to content

pdf_choice_widget_options2: avoid core dump with _GLIBCXX_ASSERTIONS#55

Open
mjg wants to merge 1 commit intoArtifexSoftware:masterfrom
mjg:widgets-avoid-core-dump
Open

pdf_choice_widget_options2: avoid core dump with _GLIBCXX_ASSERTIONS#55
mjg wants to merge 1 commit intoArtifexSoftware:masterfrom
mjg:widgets-avoid-core-dump

Conversation

@mjg
Copy link
Contributor

@mjg mjg commented Feb 8, 2025

From a C programmer's view, &opts[0] == opts, but for the vector class in stdc++ there is a difference in if, where and when the existence of a zeroth element is checked. This matters for "empty" vectors only, but depending on g++/stdc++ version and flags this may throw an unexpected assertion and abort on run time. Noticed with gcc 15 on Fedora rawhide (42).

Replace &opts[0] by opts.data() which gives the pointer to the data storage of the vector, which is what pdf_choice_widget_options expects.

From a C programmer's view, &opts[0] == opts, but for the vector class
in stdc++ there is a difference in if, where and when the existence of a
zeroth element is checked. This matters for "empty" vectors only, but
depending on g++/stdc++ version and flags this may throw an unexpected
assertion and abort on run time. Noticed with gcc 15 on Fedora rawhide
(42).

Replace &opts[0] by opts.data() which gives the pointer to the data
storage of the vector, which is what pdf_choice_widget_options expects.
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.

1 participant