diff options
author | Glenn Kasten <gkasten@google.com> | 2011-01-09 09:50:10 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2011-01-17 11:32:11 -0800 |
commit | 144a5d3c86acdebeb3af53c03325a85d44b06679 (patch) | |
tree | d074badefa119906bef5c39c127cc0e5a3d8a459 /libc | |
parent | 015610e64eb728dd031c6b1730b70460d9d298b8 (diff) | |
download | bionic-144a5d3c86acdebeb3af53c03325a85d44b06679.zip bionic-144a5d3c86acdebeb3af53c03325a85d44b06679.tar.gz bionic-144a5d3c86acdebeb3af53c03325a85d44b06679.tar.bz2 |
Bug 3330205 Thread safety for bignum powers of 5
Change-Id: I739a06f9037a9fb643276f61601f0f3e192581b8
Diffstat (limited to 'libc')
-rw-r--r-- | libc/stdlib/strtod.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c index 2851506..ab637a1 100644 --- a/libc/stdlib/strtod.c +++ b/libc/stdlib/strtod.c @@ -754,6 +754,7 @@ mult } static Bigint *p5s; + static pthread_mutex_t p5s_mutex = PTHREAD_MUTEX_INITIALIZER; static Bigint * pow5mult @@ -775,11 +776,13 @@ pow5mult if (!(k = (unsigned int) k >> 2)) return b; + mutex_lock(&p5s_mutex); if (!(p5 = p5s)) { /* first time */ p5 = i2b(625); if (p5 == BIGINT_INVALID) { Bfree(b); + mutex_unlock(&p5s_mutex); return p5; } p5s = p5; @@ -797,6 +800,7 @@ pow5mult p51 = mult(p5,p5); if (p51 == BIGINT_INVALID) { Bfree(b); + mutex_unlock(&p5s_mutex); return p51; } p5->next = p51; @@ -804,6 +808,7 @@ pow5mult } p5 = p51; } + mutex_unlock(&p5s_mutex); return b; } |