mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 16:48:49 -05:00
examples/fopen: fix comparison
As want is size_t, (file->buffer_pos - want) is unsigned, so checking if it's less than zero makes no sense. Check if file->buffer_pos is less than want instead to avoid the unsigned integer wraparound. Closes https://github.com/curl/curl/pull/3975
This commit is contained in:
parent
e23c52b329
commit
992083b1ab
@ -211,7 +211,7 @@ static int fill_buffer(URL_FILE *file, size_t want)
|
|||||||
static int use_buffer(URL_FILE *file, size_t want)
|
static int use_buffer(URL_FILE *file, size_t want)
|
||||||
{
|
{
|
||||||
/* sort out buffer */
|
/* sort out buffer */
|
||||||
if((file->buffer_pos - want) <= 0) {
|
if(file->buffer_pos <= want) {
|
||||||
/* ditch buffer - write will recreate */
|
/* ditch buffer - write will recreate */
|
||||||
free(file->buffer);
|
free(file->buffer);
|
||||||
file->buffer = NULL;
|
file->buffer = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user