Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Segfault because metafy() writes to a const char
On Feb 18, 4:30pm, Theo Buehler wrote:
} Subject: Segfault because metafy() writes to a const char
}
} The following patch fixes this problem for me, however, it effectively
} undoes a patch discussed in this thread:
}
}
} http://www.zsh.org/mla/workers/2013/msg01089.html
}
} and, especially here:
}
} http://www.zsh.org/mla/workers/2013/msg01091.html
If you look at the followup to that message:
http://www.zsh.org/mla/workers/2013/msg01092.html
("we need to change the caller") The fix should be this:
diff --git a/Src/module.c b/Src/module.c
index 7dd4701..368254c 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -1601,7 +1601,7 @@ do_load_module(char const *name, int silent)
#ifdef HAVE_DLERROR
char *errstr = dlerror();
zwarn("failed to load module `%s': %s", name,
- errstr ? metafy(errstr, -1, META_USEHEAP) : "empty module path");
+ errstr ? metafy(errstr, -1, META_HEAPDUP) : "empty module path");
#else
zwarn("failed to load module: %s", name);
#endif
(Could probably even use META_STATIC there, the dlerror string is not very
likely to be too long for PATH_MAX.)
It still seems as though we should be able to avoid nul-terminating a
string that's already nul-terminated without changing the call sign of
metafy().
Messages sorted by:
Reverse Date,
Date,
Thread,
Author