dns_utils: simplify string handling and fix leak

This commit is contained in:
moneromooo-monero 2015-08-27 22:21:07 +01:00
parent ae5f28cb51
commit 4ef0da184d
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -301,11 +301,7 @@ std::vector<std::string> DNSResolver::get_txt_record(const std::string& url, boo
{ {
for (size_t i=0; result->data[i] != NULL; i++) for (size_t i=0; result->data[i] != NULL; i++)
{ {
// plz fix this, but this does NOT work and spills over into parts of memory it shouldn't: records.push_back(result.ptr->data[i]); records.push_back(std::string(result->data[i]+1, result->len[i]-1));
char *restxt;
restxt = (char*) calloc(result->len[i]+1, 1);
memcpy(restxt, result->data[i]+1, result->len[i]-1);
records.push_back(restxt);
} }
} }
} }