vfs: check userland buffers before reading them.
[haiku.git] / src / libs / libunwind / mi / _ReadSLEB.c
blobc041e37a0543f055876a53759e17d8a09193d6bf
1 #include <libunwind.h>
3 unw_word_t
4 _ReadSLEB (unsigned char **dpp)
6 unsigned shift = 0;
7 unw_word_t byte, result = 0;
8 unsigned char *bp = *dpp;
10 while (1)
12 byte = *bp++;
13 result |= (byte & 0x7f) << shift;
14 shift += 7;
15 if ((byte & 0x80) == 0)
16 break;
19 if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0)
20 /* sign-extend negative value */
21 result |= ((unw_word_t) -1) << shift;
23 *dpp = bp;
24 return result;