Attached is a patch that fixes a crash with musl.

Commit message:

"f_syntax: set regexec nmatch to 0.

this is correct according to POSIX with REG_NOSUB, but it doesn't make
much sense to set to > 0 when pmatch is NULL and will crash on musl"

I reported this to the musl project and a fix is commited:
http://git.musl-libc.org/cgit/musl/commit/?id=72ed3d47e567b1635a35d3c1d174c8a8b2787e30

Kind regards,
Hiltjo
From ed2af64ee8c1b6f976e3223dc2de325e10f228a0 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <hil...@codemadness.org>
Date: Fri, 18 Jul 2014 00:27:11 +0000
Subject: [PATCH] f_syntax: set regexec nmatch to 0.

this is correct according to POSIX with REG_NOSUB, but it doesn't make much
sense to set to > 0 when pmatch is NULL and will crash on musl (reported to
the musl project too).
---
 sandy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sandy.c b/sandy.c
index 5d049f3..0305d10 100644
--- a/sandy.c
+++ b/sandy.c
@@ -482,7 +482,7 @@ f_syntax(const Arg *arg) {
 	statusflags|=S_DirtyScr;
 	for(i=0; i<LENGTH(syntaxes); i++)
 		if((arg && arg->v) ? !strcmp(arg->v, syntaxes[i].name)
-				   : !regexec(syntax_file_res[i], filename, 1, NULL, 0)) {
+				   : !regexec(syntax_file_res[i], filename, 0, NULL, 0)) {
 			for(j=0; j<SYN_COLORS; j++) {
 				if((syntx >= 0) && syntax_res[syntx][j]) regfree(syntax_res[syntx][j]);
 				if(syntaxes[i].re_text[j] && regcomp(syntax_res[i][j], syntaxes[i].re_text[j], REG_EXTENDED|REG_NEWLINE)) i_die("Faulty regex.\n");
-- 
2.0.2

Reply via email to