diff options
Diffstat (limited to 'src/examples/demo_https.c')
-rw-r--r-- | src/examples/demo_https.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c index 806464a2..88b01bbf 100644 --- a/src/examples/demo_https.c +++ b/src/examples/demo_https.c | |||
@@ -434,7 +434,7 @@ struct UploadContext | |||
434 | * @param ret string to update, NULL or 0-terminated | 434 | * @param ret string to update, NULL or 0-terminated |
435 | * @param data data to append | 435 | * @param data data to append |
436 | * @param size number of bytes in 'data' | 436 | * @param size number of bytes in 'data' |
437 | * @return MHD_NO on allocation failure, MHD_YES on success | 437 | * @return #MHD_NO on allocation failure, #MHD_YES on success |
438 | */ | 438 | */ |
439 | static int | 439 | static int |
440 | do_append (char **ret, | 440 | do_append (char **ret, |
@@ -448,13 +448,18 @@ do_append (char **ret, | |||
448 | old_len = 0; | 448 | old_len = 0; |
449 | else | 449 | else |
450 | old_len = strlen (*ret); | 450 | old_len = strlen (*ret); |
451 | buf = malloc (old_len + size + 1); | 451 | if (NULL == (buf = malloc (old_len + size + 1))) |
452 | if (NULL == buf) | ||
453 | return MHD_NO; | 452 | return MHD_NO; |
454 | memcpy (buf, *ret, old_len); | ||
455 | if (NULL != *ret) | 453 | if (NULL != *ret) |
456 | free (*ret); | 454 | { |
457 | memcpy (&buf[old_len], data, size); | 455 | memcpy (buf, |
456 | *ret, | ||
457 | old_len); | ||
458 | free (*ret); | ||
459 | } | ||
460 | memcpy (&buf[old_len], | ||
461 | data, | ||
462 | size); | ||
458 | buf[old_len + size] = '\0'; | 463 | buf[old_len + size] = '\0'; |
459 | *ret = buf; | 464 | *ret = buf; |
460 | return MHD_YES; | 465 | return MHD_YES; |