Skip to content

Conversation

@nmeum
Copy link

@nmeum nmeum commented Sep 7, 2025

This PR contains a follow-up for eda57f5, improving null-termination for extended attributes. Further, it ensures zero initialization of the reference counter used for footnotes. Lastly, it fixes out-of-bounds reads caused by lack of string null termination in the changes added in 6ff6878 (which made width/height a string but didn't ensure their null termination).

Since the generator uses the S(<field>) > 0 idiom to check for their presence, and I didn't want to modify these checks, I used a trick I discovered elsewhere in the codebase to exclude them from the size count. Let me know if you prefer a different solution.

Fixes #298

These are later output via printf in linkysize(), therefore these two
strings must always be null terminated. In order to ensure that we can
still use `S(width) > 0` to check for their presence, we pretend that
the null byte doesn't exist.
@nmeum
Copy link
Author

nmeum commented Sep 8, 2025

Rebased against current main and fixed some additional memory errors related to footnotes.

@sthen
Copy link

sthen commented Sep 8, 2025

This fixes issues with footnote numbering that I see since 3.0.1 on OpenBSD with default malloc options (see https://man.openbsd.org/malloc.3 for info; in particular the default enables one level of 'J' where the first part of malloc allocations have 0xdf written over them) that go away if I disable that by setting MALLOC_OPTIONS=j (lowercase).

@Orc
Copy link
Owner

Orc commented Sep 8, 2025 via email

@sthen
Copy link

sthen commented Sep 8, 2025

you're welcome. more proof that a diverse ecosystem helps get problems fixed :)

@sthen
Copy link

sthen commented Sep 10, 2025

btw, just looking over release notes and noticed you've run into a problem that I used to have but eventually found a workaround - if you'd like to export a patch from a github pull request, just add .patch to the main url, e.g.: https://github.com/Orc/discount/pull/299.patch

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.

Test failure after upgrade to 3.0.1

3 participants