src: fix intermittent SIGSEGV in resolveTxt

Fixes a SIGSEGV by making sure `txt_chunk` is not empty before setting
it on `txt_records`

Fixes: https://github.com/joyent/node/issues/9285
PR-URL: https://github.com/joyent/node/pull/9300
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
This commit is contained in:
Evan Lucas authored and James M Snell committed 2015-08-27 14:19:44 -04:00
1 parent 1f7257b02d
commit 261fa3620f
2 files changed
+11 -2

No files matched your search

+3 -2
View File
@@ -633,8 +633,9 @@ class QueryTxtWrap: public QueryWrap {
}
txt_chunk->Set(j++, txt);
}
// Push last chunk
txt_records->Set(i, txt_chunk);
// Push last chunk if it isn't empty
if (!txt_chunk.IsEmpty())
txt_records->Set(i, txt_chunk);
ares_free_data(txt_out);
+8
View File
@@ -0,0 +1,8 @@
var common = require('../common');
var assert = require('assert');
var dns = require('dns');
dns.resolveTxt('www.microsoft.com', function(err, records) {
assert.equal(err, null);
assert.equal(records.length, 0);
});