Skip to content

Commit e435a01

Browse files
evanlucasEvan Lucas
authored and
Evan Lucas
committed
src: fix intermittent SIGSEGV in resolveTxt
Fixes a SIGSEGV by making sure `txt_chunk` is not empty before setting it on `txt_records` PR-URL: #960 Reviewed-By: Rod Vagg <[email protected]>
1 parent 0af4c9e commit e435a01

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cares_wrap.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,9 @@ class QueryTxtWrap: public QueryWrap {
611611
}
612612
txt_chunk->Set(j++, txt);
613613
}
614-
// Push last chunk
615-
txt_records->Set(i, txt_chunk);
614+
// Push last chunk if it isn't empty
615+
if (!txt_chunk.IsEmpty())
616+
txt_records->Set(i, txt_chunk);
616617

617618
ares_free_data(txt_out);
618619

test/internet/test-dns-txt-sigsegv.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var common = require('../common');
2+
var assert = require('assert');
3+
var dns = require('dns');
4+
5+
dns.resolveTxt('www.microsoft.com', function(err, records) {
6+
assert.equal(err, null);
7+
assert.equal(records.length, 0);
8+
});

0 commit comments

Comments
 (0)