[PATCH] Fix getting environment variables for sanitizers needs on FreeBSD

Viktor Kutuzov vkutuzov at accesssoftek.com
Tue Jun 24 01:52:02 PDT 2014


================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:325
@@ +324,3 @@
+  uptr NameLen = internal_strlen(name);
+  for (char **Env = ::environ; *Env != NULL; Env++) {
+    if (internal_strncmp(*Env, name, NameLen) == 0 && (*Env)[NameLen] == '=')
----------------
Alexey Samsonov wrote:
> Ed Maste wrote:
> > Note that ::environ may be null - see the libc implementation here:
> > http://svnweb.freebsd.org/base/head/lib/libc/stdlib/getenv.c?revision=253413&view=markup#l428
> > 
> > 
> Why can't you use internal_strstr function here?
I believe strstr() doesn't look up through an array of pointers? Or, if you mean to replace ##internal_strncmp(*Env, name, NameLen) == 0## with ##internal_strstr(*Env, name) == *Env##, well, it would look a bit awkward to me. But no problem to fix, of course.

http://reviews.llvm.org/D4229






More information about the llvm-commits mailing list