]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change VG_(strncpy_safely) to use VG_(strncpy) to get the same padding
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 24 Jul 2014 12:50:03 +0000 (12:50 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 24 Jul 2014 12:50:03 +0000 (12:50 +0000)
behaviour.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14186

coregrind/m_debuginfo/debuginfo.c
coregrind/m_libcbase.c

index 85d3ca853597f8017cc38a30f1eae0b8a3c6aeb8..99157b2c2a4a9e841e4fbd48b9f88d78dd9c118c 100644 (file)
@@ -1870,7 +1870,6 @@ Bool VG_(get_objname) ( Addr a, HChar* buf, Int nbuf )
           && di->text_avma <= a 
           && a < di->text_avma + di->text_size) {
          VG_(strncpy_safely)(buf, di->fsm.filename, nbuf);
-         buf[nbuf-1] = 0;
          return True;
       }
    }
index 56a70397407f7b544b9be58aa3568d2f75a4dc42..97af7c7c2dfd2eeba47128a778a1759d6ae88192 100644 (file)
@@ -304,14 +304,8 @@ void VG_(strncpy_safely) ( HChar* dest, const HChar* src, SizeT ndest )
 {
    libcbase_assert(ndest > 0);
 
-   SizeT i = 0;
-   while (True) {
-      dest[i] = 0;
-      if (src[i] == 0) return;
-      if (i >= ndest-1) return;
-      dest[i] = src[i];
-      i++;
-   }
+   VG_(strncpy)(dest, src, ndest);
+   dest[ndest - 1] = '\0';
 }
 
 HChar* VG_(strncpy) ( HChar* dest, const HChar* src, SizeT ndest )