Fossil SCM

Fix a potential integer overflow in the bag_hash() function.

drh 2024-03-15 12:59 trunk
Commit 34276d22e558fbde2705ca0457caefb647b7f387602aca4e0a7621ae65d05f13
1 file changed +1 -1
+1 -1
--- src/bag.c
+++ src/bag.c
@@ -74,11 +74,11 @@
7474
}
7575
7676
/*
7777
** The hash function
7878
*/
79
-#define bag_hash(i) (i*101)
79
+#define bag_hash(i) (((u64)(i))*101)
8080
8181
/*
8282
** Change the size of the hash table on a bag so that
8383
** it contains N slots
8484
**
8585
--- src/bag.c
+++ src/bag.c
@@ -74,11 +74,11 @@
74 }
75
76 /*
77 ** The hash function
78 */
79 #define bag_hash(i) (i*101)
80
81 /*
82 ** Change the size of the hash table on a bag so that
83 ** it contains N slots
84 **
85
--- src/bag.c
+++ src/bag.c
@@ -74,11 +74,11 @@
74 }
75
76 /*
77 ** The hash function
78 */
79 #define bag_hash(i) (((u64)(i))*101)
80
81 /*
82 ** Change the size of the hash table on a bag so that
83 ** it contains N slots
84 **
85

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button