]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(_dl_important_hwcaps): Fix creation of .str elements in the returned
authorUlrich Drepper <drepper@redhat.com>
Sat, 2 Mar 2002 10:33:58 +0000 (10:33 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 2 Mar 2002 10:33:58 +0000 (10:33 +0000)
data structure.

sysdeps/generic/dl-sysdep.c

index 8d182be9e93d408a3496103e81a7fda7877c9ee8..62ca4aaaca37c4221c74d4f5f7429a490f31afac 100644 (file)
@@ -1,5 +1,5 @@
 /* Operating system support for run-time dynamic linker.  Generic Unix version.
-   Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998,2000,2001,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -338,15 +338,16 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
       temp[m].len = platform_len;
       ++m;
     }
+  assert (m == cnt);
 
   /* Determine the total size of all strings together.  */
   if (cnt == 1)
     total = temp[0].len;
   else
     {
-      total = (1 << (cnt - 2)) * (temp[0].len + temp[cnt - 1].len + 2);
+      total = (1UL << (cnt - 2)) * (temp[0].len + temp[cnt - 1].len + 2);
       for (n = 1; n + 1 < cnt; ++n)
-       total += (1 << (cnt - 3)) * (temp[n].len + 1);
+       total += (1UL << (cnt - 3)) * (temp[n].len + 1);
     }
 
   /* The result structure: we use a very compressed way to store the
@@ -428,12 +429,11 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
   rp = &result[2];
   while (n != (1UL << (cnt - 1)))
     {
-      if ((n & 1) != 0)
+      if ((--n & 1) != 0)
        rp[0].str = rp[-2].str + rp[-2].len;
       else
        rp[0].str = rp[-1].str;
       ++rp;
-      --n;
     }
 
   /* The second have starts right after the first part of the string of