From 5eb499d73e52be6518b9e3e705be220788529ede Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Sat, 23 Aug 2014 05:49:12 -0500 Subject: [PATCH] Tweak the nil encoding logic I must've managed to miss the PR update from Stanislav the other day when merging this. --- c_src/encoder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/c_src/encoder.c b/c_src/encoder.c index b6ea141..992b5d5 100644 --- a/c_src/encoder.c +++ b/c_src/encoder.c @@ -713,11 +713,15 @@ encode_iter(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) stack = enif_make_list_cell(env, e->atoms->ref_array, stack); stack = enif_make_list_cell(env, item, stack); } else if(enif_compare(curr, e->atoms->atom_null) == 0 - || (e->use_nil && enif_compare(curr, e->atoms->atom_nil) == 0)) { if(!enc_literal(e, "null", 4)) { ret = enc_error(e, "null"); goto done; - } + } + } else if(e->use_nil && enif_compare(curr, e->atoms->atom_nil) == 0)) { + if(!enc_literal(e, "null", 4)) { + ret = enc_error(e, "null"); + goto done; + } } else if(enif_compare(curr, e->atoms->atom_true) == 0) { if(!enc_literal(e, "true", 4)) { ret = enc_error(e, "true");