fix memory leak in src/main.c (accepted by upstream)

This commit is contained in:
Kamil Dudka 2009-03-12 10:20:53 +00:00
parent ce1683b0ab
commit 8acdb5038c
2 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,39 @@
diff -ruNp curl-7.19.4.orig/include/curl/curl.h curl-7.19.4/include/curl/curl.h
--- curl-7.19.4.orig/include/curl/curl.h 2009-03-03 00:05:31.000000000 +0100
+++ curl-7.19.4/include/curl/curl.h 2009-03-10 14:49:47.017943954 +0100
@@ -1510,7 +1510,7 @@ CURL_EXTERN void curl_free(void *p);
* DESCRIPTION
*
* curl_global_init() should be invoked exactly once for each application that
- * uses libcurl
+ * uses libcurl and before any call of other libcurl function
*/
CURL_EXTERN CURLcode curl_global_init(long flags);
diff -ruNp curl-7.19.4.orig/src/main.c curl-7.19.4/src/main.c
--- curl-7.19.4.orig/src/main.c 2009-02-17 10:10:21.000000000 +0100
+++ curl-7.19.4/src/main.c 2009-03-10 14:49:50.297971916 +0100
@@ -3969,6 +3969,12 @@ operate(struct Configurable *config, int
memset(&heads, 0, sizeof(struct OutStruct));
+ /* initialize curl library - do not call any libcurl functions before */
+ if (main_init() != CURLE_OK) {
+ helpf(config->errors, "error initializing curl library\n");
+ return CURLE_FAILED_INIT;
+ }
+
#ifdef CURLDEBUG
/* this sends all memory debug messages to a logfile named memdump */
env = curlx_getenv("CURL_MEMDEBUG");
@@ -4015,10 +4021,6 @@ operate(struct Configurable *config, int
#endif
/* inits */
- if (main_init() != CURLE_OK) {
- helpf(config->errors, "error initializing curl library\n");
- return CURLE_FAILED_INIT;
- }
config->postfieldsize = -1;
config->showerror=TRUE;
config->use_httpget=FALSE;

View File

@ -1,13 +1,14 @@
Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
Name: curl
Version: 7.19.4
Release: 3%{?dist}
Release: 4%{?dist}
License: MIT
Group: Applications/Internet
Source: http://curl.haxx.se/download/%{name}-%{version}.tar.bz2
Patch1: curl-7.15.3-multilib.patch
Patch2: curl-7.16.0-privlibs.patch
Patch3: curl-7.17.1-badsocket.patch
Patch4: curl-7.19.4-tool-leak.patch
Provides: webclient
URL: http://curl.haxx.se/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -52,6 +53,7 @@ use cURL's capabilities internally.
%patch1 -p1 -b .multilib
%patch2 -p1 -b .privlibs
%patch3 -p1 -b .badsocket
%patch4 -p1 -b .toolleak
# Convert docs to UTF-8
for f in CHANGES README; do
@ -89,7 +91,7 @@ install -m 644 docs/libcurl/libcurl.m4 $RPM_BUILD_ROOT/%{_datadir}/aclocal
%define _curlbuild32_h curlbuild-32.h
%define _curlbuild64_h curlbuild-64.h
%ifarch ppc64 s390x x86_64 ia64 alpha sparc64
%if %{__isa_bits} == 64
%define _curlbuild_h %{_curlbuild64_h}
%else
%define _curlbuild_h %{_curlbuild32_h}
@ -143,6 +145,10 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/aclocal/libcurl.m4
%changelog
* Thu Mar 12 2009 Kamil Dudka <kdudka@redhat.com> 7.19.4-4
- fix memory leak in src/main.c (accepted by upstream)
- avoid using %ifarch
* Wed Mar 11 2009 Kamil Dudka <kdudka@redhat.com> 7.19.4-3
- make libcurl-devel multilib-ready (bug #488922)