File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -38,23 +38,18 @@ static int fuzz_builtin_float(const char* data, size_t size) {
3838static int fuzz_builtin_int (const char * data , size_t size ) {
3939 /* Ignore test cases with very long ints to avoid timeouts
4040 int("9" * 1000000) is not a very interesting test caase */
41- if (size > MAX_INT_TEST_SIZE ) {
41+ if (size < 1 || size > MAX_INT_TEST_SIZE ) {
4242 return 0 ;
4343 }
44- /* Pick a random valid base. (When the fuzzed function takes extra
45- parameters, it's somewhat normal to hash the input to generate those
46- parameters. We want to exercise all code paths, so we do so here.) */
47- int base = Py_HashBuffer (data , size ) % 37 ;
44+ // Use the first byte to pick a base
45+ int base = ((unsigned char ) data [0 ]) % 37 ;
4846 if (base == 1 ) {
4947 // 1 is the only number between 0 and 36 that is not a valid base.
5048 base = 0 ;
5149 }
52- if (base == -1 ) {
53- return 0 ; // An error occurred, bail early.
54- }
55- if (base < 0 ) {
56- base = - base ;
57- }
50+
51+ data += 1 ;
52+ size -= 1 ;
5853
5954 PyObject * s = PyUnicode_FromStringAndSize (data , size );
6055 if (s == NULL ) {
You can’t perform that action at this time.
0 commit comments