ref-napi
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -581,3 +581,3 @@ 'use strict'; | ||
} | ||
const size = buffer.length - offset; | ||
const size = buffer.length - offset - 1; | ||
const len = buffer.write(string, offset, size, encoding); | ||
@@ -584,0 +584,0 @@ buffer.writeUInt8(0, offset + len); // NUL terminate |
@@ -24,3 +24,3 @@ { | ||
], | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"license": "MIT", | ||
@@ -27,0 +27,0 @@ "author": "Anna Henningsen <anna@addaleax.net>", |
@@ -47,7 +47,11 @@ 'use strict'; | ||
setImmediate(() => { | ||
assert(buf_gc, '"buf" has not been garbage collected'); | ||
gc(); | ||
setImmediate(() => { | ||
assert(o_gc, '"o" has not been garbage collected'); | ||
done(); | ||
assert(buf_gc, '"buf" has not been garbage collected'); | ||
gc(); | ||
setImmediate(() => { | ||
setImmediate(() => { | ||
assert(o_gc, '"o" has not been garbage collected'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -54,0 +58,0 @@ }); |
@@ -49,4 +49,6 @@ 'use strict'; | ||
setImmediate(() => { | ||
assert(child_gc, '"child" has not been garbage collected'); | ||
done(); | ||
setImmediate(() => { | ||
assert(child_gc, '"child" has not been garbage collected'); | ||
done(); | ||
}); | ||
}); | ||
@@ -53,0 +55,0 @@ }); |
@@ -34,2 +34,16 @@ 'use strict'; | ||
}); | ||
it('should not write the terminating 0 out of bounds', function() { | ||
const wholebuf = Buffer.alloc(20, 127); | ||
const buf = wholebuf.subarray(0, 10); | ||
const str = 'hello world'; | ||
buf.writeCString(str); | ||
for (let i = 0; i < buf.length - 1; i++) { | ||
assert.strictEqual(str.charCodeAt(i), buf[i]); | ||
} | ||
assert.strictEqual(0, buf[buf.length - 1]); | ||
for (let i = buf.length; i < wholebuf.length; i++) { | ||
assert.strictEqual(127, wholebuf[i]); | ||
} | ||
}); | ||
}); | ||
@@ -36,0 +50,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2415071
3311