Skip to content

Commit

Permalink
Merge 5981b31 into aaa16f8
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Oct 4, 2017
2 parents aaa16f8 + 5981b31 commit 3122515
Show file tree
Hide file tree
Showing 6 changed files with 2,607 additions and 2,532 deletions.
6 changes: 3 additions & 3 deletions lib/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
# Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -54,7 +54,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \
curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \
x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \
mime.c
mime.c setopt.c

LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
Expand All @@ -73,7 +73,7 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \
curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \
x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \
curl_printf.h system_win32.h rand.h mime.h
curl_printf.h system_win32.h rand.h mime.h setopt.h

LIB_RCFILES = libcurl.rc

Expand Down
37 changes: 36 additions & 1 deletion lib/easy.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include "multiif.h"
#include "sigpipe.h"
#include "ssh.h"
#include "setopt.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
Expand Down Expand Up @@ -861,6 +862,40 @@ CURLcode curl_easy_getinfo(struct Curl_easy *data, CURLINFO info, ...)
return result;
}

static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
{
CURLcode result = CURLE_OK;
enum dupstring i;

/* Copy src->set into dst->set first, then deal with the strings
afterwards */
dst->set = src->set;

/* clear all string pointers first */
memset(dst->set.str, 0, STRING_LAST * sizeof(char *));

/* duplicate all strings */
for(i = (enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) {
result = Curl_setstropt(&dst->set.str[i], src->set.str[i]);
if(result)
return result;
}

/* duplicate memory areas pointed to */
i = STRING_COPYPOSTFIELDS;
if(src->set.postfieldsize && src->set.str[i]) {
/* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */
dst->set.str[i] = Curl_memdup(src->set.str[i],
curlx_sotouz(src->set.postfieldsize));
if(!dst->set.str[i])
return CURLE_OUT_OF_MEMORY;
/* point to the new copy */
dst->set.postfields = dst->set.str[i];
}

return CURLE_OK;
}

/*
* curl_easy_duphandle() is an external interface to allow duplication of a
* given input easy handle. The returned handle will be a new working handle
Expand Down Expand Up @@ -888,7 +923,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
outcurl->state.headersize = HEADERSIZE;

/* copy all userdefined values */
if(Curl_dupset(outcurl, data))
if(dupset(outcurl, data))
goto fail;

/* the connection cache is setup on demand */
Expand Down
Loading

0 comments on commit 3122515

Please sign in to comment.