Skip to content

Commit 46ebaa0

Browse files
committed
Encoding 0 length data, returns '' instead of null
1 parent b8dee2e commit 46ebaa0

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
170170
Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) {
171171
HandleScope scope;
172172

173-
if (!len) return scope.Close(Null());
173+
if (!len) return scope.Close(String::Empty());
174174

175175
if (encoding == BINARY) {
176176
const unsigned char *cbuf = static_cast<const unsigned char*>(buf);

src/node_child_process.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ void ChildProcess::on_read(evcom_reader *r, const void *buf, size_t len) {
200200
enum encoding encoding = isSTDOUT ?
201201
child->stdout_encoding_ : child->stderr_encoding_;
202202

203-
Local<Value> data = Encode(buf, len, encoding);
203+
// TODO emit 'end' event instead of null.
204+
205+
Local<Value> data = len ? Encode(buf, len, encoding) : Local<Value>::New(Null());
204206
child->Emit(isSTDOUT ? output_symbol : error_symbol, 1, &data);
205207
child->MaybeShutdown();
206208
}

0 commit comments

Comments
 (0)