src/test/SDL_test_fuzzer.c
changeset 6872 2f4c95464651
parent 6839 2494f667555c
child 6885 700f1b25f77f
     1.1 --- a/src/test/SDL_test_fuzzer.c	Tue Feb 12 17:07:21 2013 -0800
     1.2 +++ b/src/test/SDL_test_fuzzer.c	Tue Feb 12 22:23:42 2013 -0800
     1.3 @@ -44,7 +44,7 @@
     1.4  #include "SDL_test.h"
     1.5  
     1.6  /** 
     1.7 - *Counter for fuzzer invocations
     1.8 + * Counter for fuzzer invocations
     1.9   */
    1.10  static int fuzzerInvocationCounter = 0;
    1.11  
    1.12 @@ -167,414 +167,268 @@
    1.13  		return (Sint32)min;
    1.14  	}
    1.15  
    1.16 -	number = SDLTest_RandomUint32(); // invocation count increment in there
    1.17 +	number = SDLTest_RandomUint32(); 
    1.18 +	/* invocation count increment in preceeding call */
    1.19  
    1.20  	return (Sint32)((number % ((max + 1) - min)) + min);
    1.21  }
    1.22  
    1.23  /*!
    1.24 - * Generates boundary values between the given boundaries.
    1.25 + * Generates a unsigned boundary value between the given boundaries.
    1.26   * Boundary values are inclusive. See the examples below.
    1.27   * If boundary2 < boundary1, the values are swapped.
    1.28   * If boundary1 == boundary2, value of boundary1 will be returned
    1.29   *
    1.30   * Generating boundary values for Uint8:
    1.31 - * BoundaryValues(sizeof(Uint8), 10, 20, True) -> [10,11,19,20]
    1.32 - * BoundaryValues(sizeof(Uint8), 10, 20, False) -> [9,21]
    1.33 - * BoundaryValues(sizeof(Uint8), 0, 15, True) -> [0, 1, 14, 15]
    1.34 - * BoundaryValues(sizeof(Uint8), 0, 15, False) -> [16]
    1.35 - * BoundaryValues(sizeof(Uint8), 0, 255, False) -> NULL
    1.36 + * BoundaryValues(UINT8_MAX, 10, 20, True) -> [10,11,19,20]
    1.37 + * BoundaryValues(UINT8_MAX, 10, 20, False) -> [9,21]
    1.38 + * BoundaryValues(UINT8_MAX, 0, 15, True) -> [0, 1, 14, 15]
    1.39 + * BoundaryValues(UINT8_MAX, 0, 15, False) -> [16]
    1.40 + * BoundaryValues(UINT8_MAX, 0, 0xFF, False) -> [0], error set
    1.41   *
    1.42   * Generator works the same for other types of unsigned integers.
    1.43   *
    1.44 - * Note: outBuffer will be allocated and needs to be freed later.
    1.45 - * If outbuffer != NULL, it'll be freed.
    1.46 - *
    1.47   * \param maxValue The biggest value that is acceptable for this data type.
    1.48   * 					For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
    1.49 - * \param pBoundary1 defines lower boundary
    1.50 - * \param pBoundary2 defines upper boundary
    1.51 + * \param boundary1 defines lower boundary
    1.52 + * \param boundary2 defines upper boundary
    1.53   * \param validDomain Generate only for valid domain (for the data type)
    1.54   *
    1.55 - * \param outBuffer The generated boundary values are put here
    1.56 - *
    1.57 - * \returns Returns the number of elements in outBuffer or -1 in case of error
    1.58 + * \returns Returns a random boundary value for the domain or 0 in case of error
    1.59   */
    1.60 -Uint32
    1.61 -SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue,
    1.62 -					Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain,
    1.63 -					Uint64 *outBuffer)
    1.64 +Uint64
    1.65 +SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
    1.66  {
    1.67 -	Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
    1.68 -	Uint64 temp;
    1.69 +        Uint64 b1, b2;
    1.70 +	Uint64 delta;
    1.71  	Uint64 tempBuf[4];
    1.72 -	int index;
    1.73 -
    1.74 -	if(outBuffer != NULL) {
    1.75 -		SDL_free(outBuffer);
    1.76 -	}
    1.77 -
    1.78 -	if(boundary1 > boundary2) {
    1.79 -		temp = boundary1;
    1.80 -		boundary1 = boundary2;
    1.81 -		boundary2 = temp;
    1.82 -	}
    1.83 +	Uint8 index;
    1.84 +	
    1.85 +        /* Maybe swap */
    1.86 +	if (boundary1 > boundary2) {
    1.87 +		b1 = boundary2;
    1.88 +		b2 = boundary1;
    1.89 +	} else {
    1.90 +		b1 = boundary1;
    1.91 +		b2 = boundary2;
    1.92 +        }
    1.93  
    1.94  	index = 0;
    1.95 -	if(boundary1 == boundary2) {
    1.96 -		tempBuf[index++] = boundary1;
    1.97 -	}
    1.98 -	else if(validDomain) {
    1.99 -		tempBuf[index++] = boundary1;
   1.100 -
   1.101 -		if(boundary1 < UINT64_MAX)
   1.102 -			tempBuf[index++] = boundary1 + 1;
   1.103 -
   1.104 -		tempBuf[index++] = boundary2 - 1;
   1.105 -		tempBuf[index++] = boundary2;
   1.106 -	}
   1.107 -	else {
   1.108 -		if(boundary1 > 0) {
   1.109 -			tempBuf[index++] = boundary1 - 1;
   1.110 +	if (validDomain == SDL_TRUE) {
   1.111 +	        if (b1 == b2) {
   1.112 +	            return b1;
   1.113 +	        }
   1.114 +	        
   1.115 +	        /* Generate up to 4 values within bounds */
   1.116 +	        delta = b2 - b1;
   1.117 +	        if (delta < 4) {
   1.118 +	            do {
   1.119 +		        tempBuf[index] = b1 + index;
   1.120 +		        index++;
   1.121 +                    } while (index < delta);
   1.122 +	        } else {
   1.123 +		  tempBuf[index] = b1;
   1.124 +		  index++;
   1.125 +		  tempBuf[index] = b1 + 1;
   1.126 +		  index++;
   1.127 +		  tempBuf[index] = b2 - 1;
   1.128 +		  index++;
   1.129 +		  tempBuf[index] = b2;
   1.130 +		  index++;
   1.131 +	        }
   1.132 +        } else {                
   1.133 +	        /* Generate up to 2 values outside of bounds */
   1.134 +		if (b1 > 0) {
   1.135 +			tempBuf[index] = b1 - 1;
   1.136 +			index++;
   1.137  		}
   1.138  
   1.139 -		if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
   1.140 -			tempBuf[index++] = boundary2 + 1;
   1.141 +		if (b2 < maxValue) {
   1.142 +			tempBuf[index] = b2 + 1;
   1.143 +			index++;
   1.144  		}
   1.145  	}
   1.146  
   1.147 -	if(index == 0) {
   1.148 -		// There are no valid boundaries
   1.149 +	if (index == 0) {
   1.150 +		/* There are no valid boundaries */
   1.151 +		SDL_Error(SDL_UNSUPPORTED);
   1.152  		return 0;
   1.153  	}
   1.154  
   1.155 -	// Create the return buffer
   1.156 -	outBuffer = (Uint64 *)SDL_malloc(index * sizeof(Uint64));
   1.157 -	if(outBuffer == NULL) {
   1.158 -		return 0;
   1.159 -	}
   1.160 +	return tempBuf[SDLTest_RandomUint8() % index];
   1.161 +}
   1.162  
   1.163 -	SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64));
   1.164 -
   1.165 -	return index;
   1.166 -}
   1.167  
   1.168  Uint8
   1.169  SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
   1.170  {
   1.171 -	Uint64 *buffer = NULL;
   1.172 -	Uint32 size;
   1.173 -	Uint32 index;
   1.174 -	Uint8 retVal;
   1.175 -
   1.176 -	// max value for Uint8
   1.177 -	const Uint64 maxValue = UINT8_MAX;
   1.178 -
   1.179 -	size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.180 +	/* max value for Uint8 */
   1.181 +	const Uint64 maxValue = UCHAR_MAX;
   1.182 +	return (Uint8)SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.183  				(Uint64) boundary1, (Uint64) boundary2,
   1.184 -				validDomain, buffer);
   1.185 -	if (buffer == NULL || size == 0) {
   1.186 -		return 0;
   1.187 -	}
   1.188 -
   1.189 -	index = SDLTest_RandomSint32() % size;
   1.190 -	retVal = (Uint8)buffer[index];
   1.191 -
   1.192 -	SDL_free(buffer);
   1.193 -
   1.194 -	fuzzerInvocationCounter++;
   1.195 -
   1.196 -	return retVal;
   1.197 +				validDomain);
   1.198  }
   1.199  
   1.200  Uint16
   1.201  SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain)
   1.202  {
   1.203 -	Uint64 *buffer = NULL;
   1.204 -	Uint32 size;
   1.205 -	Uint32 index;
   1.206 -	Uint16 retVal;
   1.207 -
   1.208 -	// max value for Uint16
   1.209 -	const Uint64 maxValue = UINT16_MAX;
   1.210 -
   1.211 -	size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.212 +	/* max value for Uint16 */
   1.213 +	const Uint64 maxValue = USHRT_MAX;
   1.214 +	return (Uint16)SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.215  				(Uint64) boundary1, (Uint64) boundary2,
   1.216 -				validDomain, buffer);
   1.217 -	if (buffer == NULL || size == 0) {
   1.218 -		return 0;
   1.219 -	}
   1.220 -
   1.221 -	index = SDLTest_RandomSint32() % size;
   1.222 -	retVal = (Uint16) buffer[index];
   1.223 -
   1.224 -	SDL_free(buffer);
   1.225 -
   1.226 -	fuzzerInvocationCounter++;
   1.227 -
   1.228 -	return retVal;
   1.229 +				validDomain);
   1.230  }
   1.231  
   1.232  Uint32
   1.233  SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain)
   1.234  {
   1.235 -	Uint64 *buffer = NULL;
   1.236 -	Uint32 size;
   1.237 -	Uint32 index;
   1.238 -	Uint32 retVal;
   1.239 -
   1.240 -	// max value for Uint32
   1.241 -	const Uint64 maxValue = UINT32_MAX;
   1.242 -
   1.243 -	size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.244 +	/* max value for Uint32 */
   1.245 +	const Uint64 maxValue = ULONG_MAX;
   1.246 +	return (Uint32)SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.247  				(Uint64) boundary1, (Uint64) boundary2,
   1.248 -				validDomain, buffer);
   1.249 -	if (buffer == NULL || size == 0) {
   1.250 -		return 0;
   1.251 -	}
   1.252 -
   1.253 -	index = SDLTest_RandomSint32() % size;
   1.254 -	retVal = (Uint32) buffer[index];
   1.255 -
   1.256 -	SDL_free(buffer);
   1.257 -
   1.258 -	fuzzerInvocationCounter++;
   1.259 -
   1.260 -	return retVal;
   1.261 +				validDomain);
   1.262  }
   1.263  
   1.264  Uint64
   1.265  SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
   1.266  {
   1.267 -	Uint64 *buffer = NULL;
   1.268 -	Uint32 size;
   1.269 -	Uint32 index;
   1.270 -	Uint64 retVal;
   1.271 -
   1.272 -	// max value for Uint64
   1.273 -	const Uint64 maxValue = UINT64_MAX;
   1.274 -
   1.275 -	size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.276 +	/* max value for Uint64 */
   1.277 +	const Uint64 maxValue = ULLONG_MAX;
   1.278 +	return SDLTest_GenerateUnsignedBoundaryValues(maxValue,
   1.279  				(Uint64) boundary1, (Uint64) boundary2,
   1.280 -				validDomain, buffer);
   1.281 -	if (buffer == NULL || size == 0) {
   1.282 -		return 0;
   1.283 -	}
   1.284 -
   1.285 -	index = SDLTest_RandomSint32() % size;
   1.286 -	retVal = (Uint64) buffer[index];
   1.287 -
   1.288 -	SDL_free(buffer);
   1.289 -
   1.290 -	fuzzerInvocationCounter++;
   1.291 -
   1.292 -	return retVal;
   1.293 +				validDomain);
   1.294  }
   1.295  
   1.296  /*!
   1.297 - * Generates boundary values between the given boundaries.
   1.298 + * Generates a signed boundary value between the given boundaries.
   1.299   * Boundary values are inclusive. See the examples below.
   1.300   * If boundary2 < boundary1, the values are swapped.
   1.301   * If boundary1 == boundary2, value of boundary1 will be returned
   1.302   *
   1.303   * Generating boundary values for Sint8:
   1.304 - * SignedBoundaryValues(sizeof(Sint8), -10, 20, True) -> [-11,-10,19,20]
   1.305 - * SignedBoundaryValues(sizeof(Sint8), -10, 20, False) -> [-11,21]
   1.306 - * SignedBoundaryValues(sizeof(Sint8), -30, -15, True) -> [-30, -29, -16, -15]
   1.307 - * SignedBoundaryValues(sizeof(Sint8), -128, 15, False) -> [16]
   1.308 - * SignedBoundaryValues(sizeof(Sint8), -128, 127, False) -> NULL
   1.309 + * SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -10, 20, True) -> [-10,-9,19,20]
   1.310 + * SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -10, 20, False) -> [-11,21]
   1.311 + * SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -30, -15, True) -> [-30, -29, -16, -15]
   1.312 + * SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -127, 15, False) -> [16]
   1.313 + * SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -127, 127, False) -> [0], error set
   1.314   *
   1.315   * Generator works the same for other types of signed integers.
   1.316   *
   1.317 - * Note: outBuffer will be allocated and needs to be freed later.
   1.318 - * If outbuffer != NULL, it'll be freed.
   1.319 - *
   1.320 - *
   1.321 - * \param minValue The smallest value  that is acceptable for this data type.
   1.322 - *					For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
   1.323 + * \param minValue The smallest value that is acceptable for this data type.
   1.324 + * 					For instance, for Uint8 -> -127, etc.
   1.325   * \param maxValue The biggest value that is acceptable for this data type.
   1.326 - * 					For instance, for Uint8 -> 127, Uint16 -> 32767 etc.
   1.327 - * \param pBoundary1 defines lower boundary
   1.328 - * \param pBoundary2 defines upper boundary
   1.329 + * 					For instance, for Uint8 -> 127, etc.
   1.330 + * \param boundary1 defines lower boundary
   1.331 + * \param boundary2 defines upper boundary
   1.332   * \param validDomain Generate only for valid domain (for the data type)
   1.333   *
   1.334 - * \param outBuffer The generated boundary values are put here
   1.335 - *
   1.336 - * \returns Returns the number of elements in outBuffer or -1 in case of error
   1.337 + * \returns Returns a random boundary value for the domain or 0 in case of error
   1.338   */
   1.339 -Uint32
   1.340 -SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
   1.341 -					Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain,
   1.342 -					Sint64 *outBuffer)
   1.343 +Sint64
   1.344 +SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue, Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
   1.345  {
   1.346 -	int index;
   1.347 +        Sint64 b1, b2;
   1.348 +	Sint64 delta;
   1.349  	Sint64 tempBuf[4];
   1.350 -	Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
   1.351 -
   1.352 -	if(outBuffer != NULL) {
   1.353 -		SDL_free(outBuffer);
   1.354 -	}
   1.355 -
   1.356 -	if(boundary1 > boundary2) {
   1.357 -		Sint64 temp = boundary1;
   1.358 -		boundary1 = boundary2;
   1.359 -		boundary2 = temp;
   1.360 -	}
   1.361 +	Uint8 index;
   1.362 +	
   1.363 +        /* Maybe swap */
   1.364 +	if (boundary1 > boundary2) {
   1.365 +		b1 = boundary2;
   1.366 +		b2 = boundary1;
   1.367 +	} else {
   1.368 +		b1 = boundary1;
   1.369 +		b2 = boundary2;
   1.370 +        }
   1.371  
   1.372  	index = 0;
   1.373 -	if(boundary1 == boundary2) {
   1.374 -		tempBuf[index++] = boundary1;
   1.375 -	}
   1.376 -	else if(validDomain) {
   1.377 -		tempBuf[index++] = boundary1;
   1.378 -
   1.379 -		if(boundary1 < LLONG_MAX)
   1.380 -			tempBuf[index++] = boundary1 + 1;
   1.381 -
   1.382 -		if(boundary2 > LLONG_MIN)
   1.383 -			tempBuf[index++] = boundary2 - 1;
   1.384 -
   1.385 -		tempBuf[index++] = boundary2;
   1.386 -	}
   1.387 -	else {
   1.388 -		if(boundary1 > minValue &&  boundary1 > LLONG_MIN) {
   1.389 -			tempBuf[index++] = boundary1 - 1;
   1.390 +	if (validDomain == SDL_TRUE) {
   1.391 +	        if (b1 == b2) {
   1.392 +	            return b1;
   1.393 +	        }
   1.394 +	        
   1.395 +	        /* Generate up to 4 values within bounds */
   1.396 +	        delta = b2 - b1;
   1.397 +	        if (delta < 4) {
   1.398 +	            do {
   1.399 +		        tempBuf[index] = b1 + index;
   1.400 +		        index++;
   1.401 +                    } while (index < delta);
   1.402 +	        } else {
   1.403 +		  tempBuf[index] = b1;
   1.404 +		  index++;
   1.405 +		  tempBuf[index] = b1 + 1;
   1.406 +		  index++;
   1.407 +		  tempBuf[index] = b2 - 1;
   1.408 +		  index++;
   1.409 +		  tempBuf[index] = b2;
   1.410 +		  index++;
   1.411 +	        }
   1.412 +        } else {                
   1.413 +	        /* Generate up to 2 values outside of bounds */
   1.414 +		if (b1 > minValue) {
   1.415 +			tempBuf[index] = b1 - 1;
   1.416 +			index++;
   1.417  		}
   1.418  
   1.419 -		if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
   1.420 -			tempBuf[index++] = boundary2 + 1;
   1.421 +		if (b2 < maxValue) {
   1.422 +			tempBuf[index] = b2 + 1;
   1.423 +			index++;
   1.424  		}
   1.425  	}
   1.426  
   1.427 -	if(index == 0) {
   1.428 -		// There are no valid boundaries
   1.429 -		return 0;
   1.430 +	if (index == 0) {
   1.431 +		/* There are no valid boundaries */
   1.432 +		SDL_Error(SDL_UNSUPPORTED);
   1.433 +		return minValue;
   1.434  	}
   1.435  
   1.436 -	// Create the return buffer
   1.437 -	outBuffer = (Sint64 *)SDL_malloc(index * sizeof(Sint64));
   1.438 -	if(outBuffer == NULL) {
   1.439 -		return 0;
   1.440 -	}
   1.441 +	return tempBuf[SDLTest_RandomUint8() % index];
   1.442 +}
   1.443  
   1.444 -	SDL_memcpy((void *)outBuffer, (void *)tempBuf, index * sizeof(Sint64));
   1.445 -
   1.446 -	return (Uint32)index;
   1.447 -}
   1.448  
   1.449  Sint8
   1.450  SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
   1.451  {
   1.452 -	// min & max values for Sint8
   1.453 -	const Sint64 maxValue = CHAR_MAX;
   1.454 -	const Sint64 minValue = CHAR_MIN;
   1.455 -
   1.456 -	Sint64 *buffer = NULL;
   1.457 -	Uint32 size;
   1.458 -	Uint32 index;
   1.459 -	Sint8 retVal;
   1.460 -
   1.461 -	size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.462 +	/* min & max values for Sint8 */
   1.463 +	const Sint64 maxValue = SCHAR_MAX;
   1.464 +	const Sint64 minValue = SCHAR_MIN;
   1.465 +	return (Sint8)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.466  				(Sint64) boundary1, (Sint64) boundary2,
   1.467 -				validDomain, buffer);
   1.468 -	if (buffer == NULL || size == 0) {
   1.469 -		return CHAR_MIN;
   1.470 -	}
   1.471 -
   1.472 -	index = SDLTest_RandomSint32() % size;
   1.473 -	retVal = (Sint8) buffer[index];
   1.474 -
   1.475 -	SDL_free(buffer);
   1.476 -
   1.477 -	fuzzerInvocationCounter++;
   1.478 -
   1.479 -	return retVal;
   1.480 +				validDomain);
   1.481  }
   1.482  
   1.483  Sint16
   1.484  SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain)
   1.485  {
   1.486 -	// min & max values for Sint16
   1.487 +	/* min & max values for Sint16 */
   1.488  	const Sint64 maxValue = SHRT_MAX;
   1.489  	const Sint64 minValue = SHRT_MIN;
   1.490 -	Sint64 *buffer = NULL;
   1.491 -	Uint32 size;
   1.492 -	Uint32 index;
   1.493 -	Sint16 retVal;
   1.494 -
   1.495 -	size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.496 -					(Sint64) boundary1, (Sint64) boundary2,
   1.497 -					validDomain, buffer);
   1.498 -	if (buffer == NULL || size == 0) {
   1.499 -		return SHRT_MIN;
   1.500 -	}
   1.501 -
   1.502 -	index = SDLTest_RandomSint32() % size;
   1.503 -	retVal = (Sint16) buffer[index];
   1.504 -
   1.505 -	SDL_free(buffer);
   1.506 -
   1.507 -	fuzzerInvocationCounter++;
   1.508 -
   1.509 -	return retVal;
   1.510 +	return (Sint16)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.511 +				(Sint64) boundary1, (Sint64) boundary2,
   1.512 +				validDomain);
   1.513  }
   1.514  
   1.515  Sint32
   1.516  SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)
   1.517  {
   1.518 -	// min & max values for Sint32
   1.519 -	const Sint64 maxValue = INT_MAX;
   1.520 -	const Sint64 minValue = INT_MIN;
   1.521 -
   1.522 -	Sint64 *buffer = NULL;
   1.523 -	Uint32 size;
   1.524 -	Uint32 index;
   1.525 -	Sint32 retVal;
   1.526 -
   1.527 -	size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.528 +	/* min & max values for Sint32 */
   1.529 +	const Sint64 maxValue = LONG_MAX;
   1.530 +	const Sint64 minValue = LONG_MIN;
   1.531 +	return (Sint32)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.532  				(Sint64) boundary1, (Sint64) boundary2,
   1.533 -				validDomain, buffer);
   1.534 -	if (buffer == NULL || size == 0) {
   1.535 -		return INT_MIN;
   1.536 -	}
   1.537 -
   1.538 -	index = SDLTest_RandomSint32() % size;
   1.539 -	retVal = (Sint32) buffer[index];
   1.540 -
   1.541 -	SDL_free(buffer);
   1.542 -
   1.543 -	fuzzerInvocationCounter++;
   1.544 -
   1.545 -	return retVal;
   1.546 +				validDomain);
   1.547  }
   1.548  
   1.549  Sint64
   1.550  SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
   1.551  {
   1.552 -	Sint64 *buffer = NULL;
   1.553 -	Uint32 size;
   1.554 -	Uint32 index;
   1.555 -	Sint64 retVal;
   1.556 -
   1.557 -	// min & max values for Sint64
   1.558 +	/* min & max values for Sint64 */
   1.559  	const Sint64 maxValue = LLONG_MAX;
   1.560  	const Sint64 minValue = LLONG_MIN;
   1.561 -
   1.562 -	size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.563 -				(Sint64) boundary1, (Sint64) boundary2,
   1.564 -				validDomain, buffer);
   1.565 -	if (buffer == NULL || size == 0) {
   1.566 -		return LLONG_MIN;
   1.567 -	}
   1.568 -
   1.569 -	index = SDLTest_RandomSint32() % size;
   1.570 -	retVal = (Sint64) buffer[index];
   1.571 -
   1.572 -	SDL_free(buffer);
   1.573 -
   1.574 -	fuzzerInvocationCounter++;
   1.575 -
   1.576 -	return retVal;
   1.577 +	return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
   1.578 +				boundary1, boundary2,
   1.579 +				validDomain);
   1.580  }
   1.581  
   1.582  float