Commit ee588fe0 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

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
parent db4215f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.
 */
+2 −2
Original line number Diff line number Diff line
@@ -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.
 */
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@

#include "curlx.h"

#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"

+4 −0
Original line number Diff line number Diff line
@@ -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);
+9 −0
Original line number Diff line number Diff line
@@ -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. */
Loading