Fix for crash reported by Michael Danilov
In case uDNS returns a NULL txt pointer, don’t try to create a std::string from it, since this will crash, See: https://sourceforge.net/p/flightgear/codetickets/2398/
This commit is contained in:
parent
f393a246ac
commit
f489232cdb
@ -156,8 +156,13 @@ static void dnscbTXT(struct dns_ctx *ctx, struct dns_rr_txt *result, void *data)
|
|||||||
r->ttl = result->dnstxt_ttl;
|
r->ttl = result->dnstxt_ttl;
|
||||||
for (int i = 0; i < result->dnstxt_nrr; i++) {
|
for (int i = 0; i < result->dnstxt_nrr; i++) {
|
||||||
//TODO: interprete the .len field of dnstxt_txt?
|
//TODO: interprete the .len field of dnstxt_txt?
|
||||||
string txt = string((char*)result->dnstxt_txt[i].txt);
|
auto rawTxt = reinterpret_cast<char*>(result->dnstxt_txt[i].txt);
|
||||||
r->entries.push_back( txt );
|
if (!rawTxt) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string txt{rawTxt};
|
||||||
|
r->entries.push_back(txt);
|
||||||
string_list tokens = simgear::strutils::split( txt, "=", 1 );
|
string_list tokens = simgear::strutils::split( txt, "=", 1 );
|
||||||
if( tokens.size() == 2 ) {
|
if( tokens.size() == 2 ) {
|
||||||
r->attributes[tokens[0]] = tokens[1];
|
r->attributes[tokens[0]] = tokens[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user