我从其他问题上了解到,这个警告不应该掉以轻心。
它似乎来自 curl_easy_perform 方法。
main.cpp中:
#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
std::string data;
size_t writeCallback(char* buf, size_t size, size_t nmemb, void* up)
{
for (int c = 0; c<size*nmemb; c++)
{
data.push_back(buf[c]);
}
return size*nmemb;
}
int main( void )
{
curl_global_init ( CURL_GLOBAL_DEFAULT );
CURL * curl;
CURLcode res;
struct curl_slist * chunk = NULL;
chunk = curl_slist_append(chunk, "X-Mashape-Authorization: XXXYYYYZZZZ" );
curl = curl_easy_init ( ) ;
if( curl )
{
std::string _query = "text=Hello";
curl_easy_setopt ( curl, CURLOPT_URL, "https://japerk-text-processing.p.mashape.com/tag/" );
curl_easy_setopt ( curl, CURLOPT_POSTFIELDS, _query.c_str() );
curl_easy_setopt ( curl, CURLOPT_WRITEFUNCTION, writeCallback );
curl_easy_setopt ( curl, CURLOPT_FOLLOWLOCATION, 1L );
#ifdef SKIP_PEER_VERIFICATION
curl_easy_setopt ( curl, CURLOPT_SSL_VERIFYPEER, 0L );
#endif
#ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt ( curl, CURLOPT_SSL_VERIFYHOST, 0L );
#endif
res = curl_easy_setopt ( curl, CURLOPT_HTTPHEADER, chunk );
res = curl_easy_perform ( curl ); // BUG: Conditional jump or move depends on uninitialised value(s)
curl_slist_free_all( chunk );
if(res != CURLE_OK)
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
使用valgrind
运行==4443== Memcheck, a memory error detector
==4443== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==4443== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==4443== Command: ./CURLTest
==4443==
==4443== Thread 2:
==4443== Syscall param sendmsg(mmsg[0].msg_hdr) points to uninitialised byte(s)
==4443== at 0x59A170B: sendmmsg (sendmmsg.c:36)
==4443== by 0x86652DE: __libc_res_nsend (res_send.c:1140)
==4443== by 0x8662B8B: __libc_res_nquery (res_query.c:226)
==4443== by 0x8663147: __libc_res_nquerydomain (res_query.c:582)
==4443== by 0x8663746: __libc_res_nsearch (res_query.c:378)
==4443== by 0xA2FFA35: _nss_dns_gethostbyname4_r (dns-host.c:314)
==4443== by 0x597B631: gaih_inet (getaddrinfo.c:849)
==4443== by 0x597EA13: getaddrinfo (getaddrinfo.c:2473)
==4443== by 0x4E77483: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E82F73: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E8089A: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x78F4E0D: start_thread (pthread_create.c:311)
==4443== Address 0x9eeb020 is on thread 2's stack
==4443==
==4443== Thread 1:
==4443== Conditional jump or move depends on uninitialised value(s)
==4443== at 0x6304908: ??? (in /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0)
==4443== by 0x62FB572: ??? (in /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0)
==4443== by 0x62F8BF5: ??? (in /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0)
==4443== by 0x4E57CAB: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E48C3A: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E60832: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E6A917: ??? (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E6B070: curl_multi_perform (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x4E62906: curl_easy_perform (in /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0)
==4443== by 0x40130C: main (in /CURLTest/CURLTest)
有些人可以帮忙吗? 这是误报,可以忽略它还是会导致问题?
由于