[compiler-rt] r259082 - [cfi] Get rid of a fixed size buffer for the library path in test.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 11:37:03 PST 2016


Author: eugenis
Date: Thu Jan 28 13:37:03 2016
New Revision: 259082

URL: http://llvm.org/viewvc/llvm-project?rev=259082&view=rev
Log:
[cfi] Get rid of a fixed size buffer for the library path in test.

Modified:
    compiler-rt/trunk/test/cfi/cross-dso/dlopen.cpp

Modified: compiler-rt/trunk/test/cfi/cross-dso/dlopen.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/cross-dso/dlopen.cpp?rev=259082&r1=259081&r2=259082&view=diff
==============================================================================
--- compiler-rt/trunk/test/cfi/cross-dso/dlopen.cpp (original)
+++ compiler-rt/trunk/test/cfi/cross-dso/dlopen.cpp Thu Jan 28 13:37:03 2016
@@ -47,6 +47,8 @@
 #include <string.h>
 #include <sys/mman.h>
 
+#include <string>
+
 struct A {
   virtual void f();
 };
@@ -91,9 +93,8 @@ int main(int argc, char *argv[]) {
   const bool test_cast = argc > 1 && strcmp(argv[1], "cast") == 0;
   const bool test_dlclose = argc > 1 && strcmp(argv[1], "dlclose") == 0;
 
-  char name[100];
-  snprintf(name, sizeof(name), "%s-so.so", argv[0]);
-  void *handle = dlopen(name, RTLD_NOW);
+  std::string name = std::string(argv[0]) + "-so.so";
+  void *handle = dlopen(name.c_str(), RTLD_NOW);
   assert(handle);
   void *(*create_B)() = (void *(*)())dlsym(handle, "create_B");
   assert(create_B);




More information about the llvm-commits mailing list