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

Alexey Samsonov vonosmas at gmail.com
Tue Jun 24 11:26:45 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] == '=')
----------------
Viktor Kutuzov wrote:
> 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.
Ah, sorry, please disregard my comment.

http://reviews.llvm.org/D4229






More information about the llvm-commits mailing list