Skip to content

Commit

Permalink
Remove #include <malloc.h> , add #include <libgen.h> (#792)
Browse files Browse the repository at this point in the history
* src/augprint.c: Remove `#include <malloc.h>`

`<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>

* src/augprint.c: Add `#include <libgen.h>`

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>

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
  • Loading branch information
ZhongRuoyu committed Dec 21, 2022
1 parent 4f3bbeb commit 7b26cbb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/augprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#include <string.h>
#include <augeas.h>
#include <errno.h>
#include <malloc.h>
#include <libgen.h> /* for basename() on FreeBSD and MacOS */
#include <sys/param.h> /* for MIN() MAX() */
#include <unistd.h>
#include "augprint.h"
Expand Down

0 comments on commit 7b26cbb

Please sign in to comment.