Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp

Issue 328153002: Roll to android/platform/ndk/681f1b744aec1b0888f4c7a68165720db9670300 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fork
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp
diff --git a/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp b/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp
index f9d291a98b2f9f4e3594567e88f2d66f512f3ee3..737488114be09e047009cdb09b7cf6493943cc86 100644
--- a/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp
+++ b/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp
@@ -7,9 +7,16 @@
// like __aeabi_atexit(), which are not normally returned by
// a call to dlsym().
+// Libc is not required to copy strings passed to putenv(). If it does
+// not then env pointers become invalid when rodata is unmapped on
+// library unload. To guard against this, putenv() strings are first
+// strdup()'ed. This is a mild memory leak.
+
#include <stdlib.h>
+#ifdef __arm__
extern "C" void __aeabi_atexit(void*);
+#endif
Anton 2014/06/11 15:31:54 Seems like this test maybe ARM specific. Do we nee
class A {
public:
@@ -17,17 +24,17 @@ class A {
x_ = rand();
const char* env = getenv("TEST_VAR");
if (!env || strcmp(env, "INIT"))
- putenv("TEST_VAR=LOAD_ERROR");
+ putenv(strdup("TEST_VAR=LOAD_ERROR"));
else
- putenv("TEST_VAR=LOADED");
+ putenv(strdup("TEST_VAR=LOADED"));
}
~A() {
const char* env = getenv("TEST_VAR");
if (!env || strcmp(env, "LOADED"))
- putenv("TEST_VAR=UNLOAD_ERROR");
+ putenv(strdup("TEST_VAR=UNLOAD_ERROR"));
else
- putenv("TEST_VAR=UNLOADED");
+ putenv(strdup("TEST_VAR=UNLOADED"));
}
int Get() const { return x_; }

Powered by Google App Engine
This is Rietveld 408576698