[FIX] Prevent issues 32/27032/2
authorDmitry Kovalenko <d.kovalenko@samsung.com>
Wed, 3 Sep 2014 11:17:00 +0000 (15:17 +0400)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Wed, 3 Sep 2014 11:24:55 +0000 (15:24 +0400)
Change-Id: I0006bb7bfb95553da95407da8bdfa352e3135360
Signed-off-by: Dmitry Kovalenko <d.kovalenko@samsung.com>
helper/libdaprobe.c
include/khash.h

index 93ca611..16d40e5 100755 (executable)
@@ -633,7 +633,7 @@ bool print_log_fmt(int msgType, const char *func_name, int line, ...)
        log.type = msgType;
 
        p = log.data;
-       n = snprintf(p, sizeof(log), "[%05d:%05d]%s:%d)", _getpid(), _gettid(),  func_name, line);
+       n = snprintf(p, sizeof(log.data), "[%05d:%05d]%s:%d)", _getpid(), _gettid(),  func_name, line);
        p += n;
 
        /* extract params */
index a4aff6f..bc728c9 100755 (executable)
@@ -155,10 +155,12 @@ static const double __ac_HASH_UPPER = 0.77;
         khint_t j = 1;                                                  \
         {                                                               \
             khint_t t = __ac_HASH_PRIME_SIZE - 1;                       \
-            while (__ac_prime_list[t] > new_n_buckets) {                \
-                --t;                                                    \
+            if (new_n_buckets < __ac_prime_list[__ac_HASH_PRIME_SIZE - 1]) { \
+                while (__ac_prime_list[t] > new_n_buckets) {            \
+                    --t;                                                \
+                }                                                       \
+                new_n_buckets = __ac_prime_list[t + 1];                 \
             }                                                           \
-            new_n_buckets = __ac_prime_list[t+1];                       \
             if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; \
             else {                                                      \
                 new_flags = (uint32_t*)malloc(((new_n_buckets>>4) + 1) * sizeof(uint32_t)); \