diff --git a/c_src/decoder.c b/c_src/decoder.c index 604a310..fc892da 100644 --- a/c_src/decoder.c +++ b/c_src/decoder.c @@ -246,11 +246,12 @@ dec_string(Decoder* d, ERL_NIF_TERM* value) } } -parse: - if(d->p[d->i-1] != '\"') { - return 0; - } + // The goto above ensures that we only + // hit this when a string is not terminated + // correctly. + return 0; +parse: if(!has_escape) { *value = enif_make_sub_binary(d->env, d->arg, st, (d->i - st - 1)); return 1; diff --git a/test/004-strings.t b/test/004-strings.t index 30fa0d5..d5e5161 100755 --- a/test/004-strings.t +++ b/test/004-strings.t @@ -6,7 +6,7 @@ main([]) -> code:add_pathz("ebin"), code:add_pathz("test"), - etap:plan(118), + etap:plan(119), util:test_good(good()), util:test_good(uescaped(), [uescape]), util:test_errors(errors()), @@ -50,6 +50,7 @@ uescaped() -> errors() -> [ + "\"", <<"\"foo">>, <<"\"", 0, "\"">>, <<"\"\\g\"">>,