diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-05-26 12:17:07 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-05-26 12:17:07 +0900 |
commit | 41842ca9f92095ae08ae54d99e9dcfeadef401df (patch) | |
tree | e74f64b4b9ffaa161f0a0e16b1c8863a959a6e50 | |
parent | 7241b7375de1eb4327f5bca21dcfc5a889b9eb72 (diff) | |
download | efl-41842ca9f92095ae08ae54d99e9dcfeadef401df.tar.gz |
efl - fix many bounds over/underflow where we use int for ptr cmp
this addresses more things brought up in comments in
fixes T3638 commentd
@fix
-rw-r--r-- | src/lib/eina/eina_file_common.c | 11 | ||||
-rw-r--r-- | src/lib/eina/eina_hash.c | 12 | ||||
-rw-r--r-- | src/lib/eina/eina_quadtree.c | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c index 8314f009a4..317a42152d 100644 --- a/src/lib/eina/eina_file_common.c +++ b/src/lib/eina/eina_file_common.c @@ -153,8 +153,15 @@ int eina_file_map_key_cmp(const unsigned long long int *key1, int key1_length EINA_UNUSED, const unsigned long long int *key2, int key2_length EINA_UNUSED) { - if (key1[0] - key2[0] == 0) return key1[1] - key2[1]; - return key1[0] - key2[0]; + if (key1[0] == key2[0]) + { + if (key1[1] == key2[1]) return 0; + if (key1[1] > key2[1]) return 1; + return -1; + } + if (key1[0] == key2[0]) return 0; + if (key1[0] > key2[0]) return 1; + return -1; } int diff --git a/src/lib/eina/eina_hash.c b/src/lib/eina/eina_hash.c index ed155e5513..b2d338d832 100644 --- a/src/lib/eina/eina_hash.c +++ b/src/lib/eina/eina_hash.c @@ -536,20 +536,24 @@ static int _eina_int32_key_cmp(const uint32_t *key1, EINA_UNUSED int key1_length, const uint32_t *key2, EINA_UNUSED int key2_length) { - return *key1 - *key2; + if (*key1 == *key2) return 0; + if (*key1 > *key2) return 1; + return -1; } static unsigned int -_eina_int64_key_length(EINA_UNUSED const uint32_t *key) +_eina_int64_key_length(EINA_UNUSED const uint64_t *key) { - return 8; + return sizeof(int64_t); } static int _eina_int64_key_cmp(const uint64_t *key1, EINA_UNUSED int key1_length, const uint64_t *key2, EINA_UNUSED int key2_length) { - return *key1 - *key2; + if (*key1 == *key2) return 0; + if (*key1 > *key2) return 1; + return -1; } static Eina_Bool diff --git a/src/lib/eina/eina_quadtree.c b/src/lib/eina/eina_quadtree.c index e163e6fe7a..246def7ba9 100644 --- a/src/lib/eina/eina_quadtree.c +++ b/src/lib/eina/eina_quadtree.c @@ -167,7 +167,9 @@ _eina_quadtree_item_cmp(const void *a, const void *b) const Eina_QuadTree_Item *i = a; const Eina_QuadTree_Item *j = b; - return i->index - j->index; + if (i->index == j->index) return 0; + if (i->index > j->index) return 1; + return -1; } static Eina_QuadTree_Root * |