summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2019-05-25 19:24:13 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2019-06-05 20:38:08 +0200
commit992083b1abe2f19947abe1d5ba01c488458f6e66 (patch)
tree741ded2075c811e9353e8ce405e6a66a8ac7df97
parente23c52b3295a525fbaae9e7ed3e7061fea6dffc2 (diff)
downloadcurl-992083b1abe2f19947abe1d5ba01c488458f6e66.tar.gz
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
-rw-r--r--docs/examples/fopen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/examples/fopen.c b/docs/examples/fopen.c
index f1706fbe6..7151addde 100644
--- a/docs/examples/fopen.c
+++ b/docs/examples/fopen.c
@@ -211,7 +211,7 @@ static int fill_buffer(URL_FILE *file, size_t want)
static int use_buffer(URL_FILE *file, size_t want)
{
/* sort out buffer */
- if((file->buffer_pos - want) <= 0) {
+ if(file->buffer_pos <= want) {
/* ditch buffer - write will recreate */
free(file->buffer);
file->buffer = NULL;