Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove #include <malloc.h> #792

Merged
merged 2 commits into from Dec 21, 2022

Conversation

ZhongRuoyu
Copy link
Contributor

Hi! Submitting this patch to fix the build error in Homebrew/homebrew-core#118025.

<malloc.h> is not present on all platforms (e.g. macOS). To use malloc, <stdlib.h> should be the place to look for malloc, and it has already been #included.

Signed-off-by: Ruoyu Zhong zhongruoyu@outlook.com

ZhongRuoyu added a commit to ZhongRuoyu/homebrew-core that referenced this pull request Dec 13, 2022
Fix submitted upstream at hercules-team/augeas#792.
Copy link

@igalic igalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

BrewTestBot pushed a commit to Homebrew/homebrew-core that referenced this pull request Dec 13, 2022
* augeas 1.14.0
* augeas: remove patch
  The patch is now in the release.
* augeas: fix build
  Fix submitted upstream at hercules-team/augeas#792.

Closes #118025.

Signed-off-by: Dawid Dziurla <9713907+dawidd6@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
Copy link
Member

@georgehansper georgehansper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

augprint compiles normally with this change, as per the description of this PR

@georgehansper
Copy link
Member

As it turns out, there is another similar problem affecting FreeBSD and brew, which causes augprint -h to fail
Can I ask that you update this PR to replace the malloc.h line with:

#include <libgen.h>        /* for basename() on FreeBSD and MacOS */

@igalic
Copy link

igalic commented Dec 19, 2022

n.b.: including libgen.h on glibc systems brings basename(3) to POSIX behaviour.

`<malloc.h>` is not present on all platforms (e.g. macOS). `<stdlib.h>`
should be the place to look for `malloc`, and it has already been
`#include`d.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
This fixes a segfault with `augprint -h` on some non-GNU platforms. See:
https://manpages.ubuntu.com/manpages/bionic/en/man3/basename.3.html

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
@ZhongRuoyu
Copy link
Contributor Author

Can I ask that you update this PR to replace the malloc.h line...

OK, done. Tested locally and confirmed that this is fixed.

n.b.: including libgen.h on glibc systems brings basename(3) to POSIX behaviour.

Thanks for bringing this up, @igalic. In this case I think it's fine since argv[0] is modifiable, but it's definitely worth some attention :)

Copy link
Member

@georgehansper georgehansper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR

@georgehansper georgehansper merged commit 7b26cbb into hercules-team:master Dec 21, 2022
@ZhongRuoyu ZhongRuoyu deleted the remove-malloc.h branch December 21, 2022 16:17
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.

None yet

3 participants