diff --git a/src/header/regex/mod.rs b/src/header/regex/mod.rs
index 30c837247543bf7f557c9c915d09360cc13953f4..79e9c411b66f322cab694ebb4f98e1cb7419a732 100644
--- a/src/header/regex/mod.rs
+++ b/src/header/regex/mod.rs
@@ -149,7 +149,7 @@ pub extern "C" fn regexec(
 
 #[no_mangle]
 #[linkage = "weak"] // redefined in GIT
-pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: size_t) {
+pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: size_t) -> size_t {
     let string = match code {
         0 => "No error\0",
         REG_NOMATCH => "No match\0",
@@ -174,6 +174,8 @@ pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char
             string.as_ptr(),
             out as *mut u8,
             string.len().min(max as usize),
-        )
+        );
     }
+
+    string.len()
 }