#976 missing ENV_UNLOCK in newlib/getenv()

MSYS
pending
Cesar Strauss
None
remind
Unknown
2013-02-06
2006-10-18
Jörg Höhle
No

Hi,

I came across this piece of MingW source code:
http://mingw.cvs.sourceforge.net/mingw/msys/rt/src/newlib/libc/stdlib/getenv_r.c?revision=1.1.1.1&view=markup
92 ENV_LOCK;
93
94 /* In some embedded systems, this does not get
set. This protects
95 newlib from dereferencing a bad pointer. */
96 if (!*p_environ)
97 return NULL;

It immediately stroke me as a place were a lock may not
be released. The other places in the code look fine:
115 ENV_UNLOCK;
116 return NULL;

I simply suggest to move ENV_LOCK after the *p_environ
early exit test.

Regards,
Jörg Höhle

Discussion

  • Earnie Boyd
    Earnie Boyd
    2013-02-05

    • labels: mingw runtime (deprecated use WSL) -->
    • status: open --> pending
    • assigned_to: Cesar Strauss
    • resolution: --> none
    • category: --> Unknown
    • milestone: --> MSYS
     
  • Earnie Boyd
    Earnie Boyd
    2013-02-05

    Cesar, can you comment on this please?

     
  • Cesar Strauss
    Cesar Strauss
    2013-02-06

    • resolution: none --> remind