aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2012-11-17 00:59:42 +0100
committerDaniel Stenberg <daniel@haxx.se>2012-11-17 13:56:38 +0100
commitee588fe088077785d9ad9263e03e1e525b074261 (patch)
tree85aea44bd6e3354311ac0c60577c2d8bacf45445 /lib
parentdb4215f14a9ee2aca01315fa8cf100915284b15d (diff)
mem-include-scan: verify memory #includes
If we use memory functions (malloc, free, strdup etc) in C sources in libcurl and we fail to include curl_memory.h or memdebug.h we either fail to properly support user-provided memory callbacks or the memory leak system of the test suite fails. After Ajit's report of a failure in the first category in http_proxy.c, I spotted a few in the second category as well. These problems are now tested for by test 1132 which runs a perl program that scans for and attempts to check that we use the correct include files if a memory related function is used in the source code. Reported by: Ajit Dhumale Bug: http://curl.haxx.se/mail/lib-2012-11/0125.html
Diffstat (limited to 'lib')
-rw-r--r--lib/dict.c2
-rw-r--r--lib/gopher.c4
-rw-r--r--lib/http_proxy.c1
-rw-r--r--lib/idn_win32.c4
-rw-r--r--lib/md5.c9
-rw-r--r--lib/non-ascii.c8
-rw-r--r--lib/nwlib.c5
-rw-r--r--lib/strdup.c6
-rw-r--r--lib/strerror.c3
9 files changed, 34 insertions, 8 deletions
diff --git a/lib/dict.c b/lib/dict.c
index 8c083736a..beebf4a23 100644
--- a/lib/dict.c
+++ b/lib/dict.c
@@ -67,10 +67,10 @@
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
+#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
-
/*
* Forward declarations.
*/
diff --git a/lib/gopher.c b/lib/gopher.c
index b4efae8cc..ac0397fe1 100644
--- a/lib/gopher.c
+++ b/lib/gopher.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -70,10 +70,10 @@
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
+#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
-
/*
* Forward declarations.
*/
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 15f011848..245e1c1f6 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -45,6 +45,7 @@
#include "curlx.h"
+#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
diff --git a/lib/idn_win32.c b/lib/idn_win32.c
index 68accdca4..9bc9cb810 100644
--- a/lib/idn_win32.c
+++ b/lib/idn_win32.c
@@ -30,6 +30,10 @@
#include "curl_multibyte.h"
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
+
#ifdef WANT_IDN_PROTOTYPES
WINBASEAPI int WINAPI IdnToAscii(DWORD, const WCHAR *, int, WCHAR *, int);
WINBASEAPI int WINAPI IdnToUnicode(DWORD, const WCHAR *, int, WCHAR *, int);
diff --git a/lib/md5.c b/lib/md5.c
index 8e580d8e4..ae5812b95 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -28,9 +28,13 @@
#include "curl_hmac.h"
#include "warnless.h"
+#include "curl_memory.h"
+
#if defined(USE_GNUTLS_NETTLE)
#include <nettle/md5.h>
+/* The last #include file should be: */
+#include "memdebug.h"
typedef struct md5_ctx MD5_CTX;
@@ -54,6 +58,8 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
#elif defined(USE_GNUTLS)
#include <gcrypt.h>
+/* The last #include file should be: */
+#include "memdebug.h"
typedef gcry_md_hd_t MD5_CTX;
@@ -436,6 +442,9 @@ static void Decode (UINT4 *output,
#endif /* CRYPTO LIBS */
+/* The last #include file should be: */
+#include "memdebug.h"
+
const HMAC_params Curl_HMAC_MD5[] = {
{
(HMAC_hinit_func) MD5_Init, /* Hash initialization function. */
diff --git a/lib/non-ascii.c b/lib/non-ascii.c
index a38680cc1..8e29227c0 100644
--- a/lib/non-ascii.c
+++ b/lib/non-ascii.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -24,12 +24,16 @@
#ifdef CURL_DOES_CONVERSIONS
+#include <curl/curl.h>
+
#include "non-ascii.h"
#include "formdata.h"
#include "sendf.h"
#include "urldata.h"
-#include <curl/curl.h>
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
#ifdef HAVE_ICONV
#include <iconv.h>
diff --git a/lib/nwlib.c b/lib/nwlib.c
index a7ea17bb2..c67342a08 100644
--- a/lib/nwlib.c
+++ b/lib/nwlib.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -32,6 +32,9 @@
#include <nks/thread.h>
#include <nks/synch.h>
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
typedef struct
{
diff --git a/lib/strdup.c b/lib/strdup.c
index 02d480c26..27014354d 100644
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -19,7 +19,9 @@
* KIND, either express or implied.
*
***************************************************************************/
-
+/*
+ * This file is 'mem-include-scan' clean. See test 1132.
+ */
#include "setup.h"
#include "strdup.h"
diff --git a/lib/strerror.c b/lib/strerror.c
index dd7d37565..0c82a53e4 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -44,6 +44,9 @@
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
const char *
curl_easy_strerror(CURLcode error)