当前位置:网站首页>VS2005 project call free() compiled with static libcurl library reported heap error
VS2005 project call free() compiled with static libcurl library reported heap error
2022-06-26 08:28:00 【Tonyfield】
curl There are many places to use strdup, but windows The next has been abandoned “strdup”, And ask for “_strdup” replace (
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strdup-wcsdup?view=vs-2019).
That's what makes libcurl Static library call free() The cause of the abnormality in the process .
Actually libcurl The differences of memory allocation and release functions under different platforms have been considered , Library implementation malloc,calloc,strdup,free Such as function , What's actually called is easy.c As defined in Curl_cmalloc,Curl_ccalloc,Curl_cstrdup,Curl_cfree A function pointer , Initialization function global_init() Will define these function pointers .
/**
* curl_global_init() globally initializes curl given a bitwise set of the
* different features of what to initialize.
*/
static CURLcode global_init(long flags, bool memoryfuncs)
{
if(initialized++)
return CURLE_OK;
if(memoryfuncs) {
/* Setup the default memory functions here (again) */
Curl_cmalloc = (curl_malloc_callback)malloc;
Curl_cfree = (curl_free_callback)free;
Curl_crealloc = (curl_realloc_callback)realloc;
Curl_cstrdup = (curl_strdup_callback)system_strdup;
Curl_ccalloc = (curl_calloc_callback)calloc;
#if defined(WIN32) && defined(UNICODE)
Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;
#endif
}
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
goto fail;
}
#ifdef WIN32
if(Curl_win32_init(flags)) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
goto fail;
}
#endif
among , Only Curl_cstrdup The default value of is special , It points to system_strdup . It can be seen that , Only in _WIN32_WCE Under defined conditions strdup Point to _strdup, Otherwise, call curlx_strdup or strdup , And because the config-win32.h In the definition of #define HAVE_STRDUP 1, So use VS Compilation will not use curlx_strdup, That's all strdup 了 .
#if defined(_WIN32_WCE)
#define system_strdup _strdup
#elif !defined(HAVE_STRDUP)
#define system_strdup curlx_strdup
#else
#define system_strdup strdup
#endifWe add here WIN32 Judge the condition , In this way visual studio Call down strdup Will point to the desired security function _strdup.
- #if defined(_WIN32_WCE)
+ #if defined(_WIN32_WCE) || defined(_WIN32) ||defined(WIN32)
#define system_strdup _strdup
#elif !defined(HAVE_STRDUP)
#define system_strdup curlx_strdup
#else
#define system_strdup strdup
#endif边栏推荐
- Learning signal integrity from scratch (SIPI) -- 3 challenges faced by Si and Si based design methods
- Assembly led on
- HEVC学习之码流分析
- Oracle 19C download installation steps
- Win10 mysql-8.0.23-winx64 solution for forgetting MySQL password (detailed steps)
- golang json unsupported value: NaN 处理
- STM32 porting mpu6050/9250 DMP official library (motion_driver_6.12) modifying and porting DMP simple tutorial
- Detailed explanation of SOC multi-core startup process
- RecyclerView Item 根据 x,y 坐标得到当前position(位置)
- Analysis of internal circuit of operational amplifier
猜你喜欢

Can the encrypted JS code and variable name be cracked and restored?

JMeter performance testing - Basic Concepts

1. error using XPath to locate tag

STM32 project design: temperature, humidity and air quality alarm, sharing source code and PCB

Opencv learning notes II

Esp8266wifi module tutorial: punctual atom atk-esp8266 for network communication, single chip microcomputer and computer, single chip microcomputer and mobile phone to send data

HEVC学习之码流分析

Jupyter的安装

Read excel table and render with FileReader object

Relationship extraction -- casrel
随机推荐
STM32 based d18s20 (one wire)
Application of wireless charging receiving chip xs016 coffee mixing cup
Idea automatically sets author information and date
How to Use Instruments in Xcode
Opencv learning notes II
Interview JS and browser
鲸会务为活动现场提供数字化升级方案
Can the encrypted JS code and variable name be cracked and restored?
Software engineering - high cohesion and low coupling
Undefined symbols for architecture i386 is related to third-party compiled static libraries
[untitled]
监听iPad键盘显示和隐藏事件
Idea uses regular expressions for global substitution
The difference between push-pull circuit drive and totem pole drive
Why are you impetuous
(5) Matrix key
Fabrication of modulation and demodulation circuit
Interview ES6
Deploy wiki system Wiki in kubesphere JS and enable Chinese full-text retrieval
51 MCU project design: Based on 51 MCU clock perpetual calendar