From 1154ce0867306e810cf62a5b41bdb0b765aa8ff3 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Sat, 7 Jan 2017 15:30:01 +0100 Subject: [PATCH] Properly handle empty/noop Writer#ldelim, fixes #625 --- src/writer.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/writer.js b/src/writer.js index 17ff8089c..0a2c4205e 100644 --- a/src/writer.js +++ b/src/writer.js @@ -519,11 +519,12 @@ WriterPrototype.ldelim = function ldelim() { var head = this.head, tail = this.tail, len = this.len; - this.reset() - .uint32(len) - .tail.next = head.next; // skip noop - this.tail = tail; - this.len += len; + this.reset().uint32(len); + if (len) { + this.tail.next = head.next; // skip noop + this.tail = tail; + this.len += len; + } return this; };