This is an automated email from the ASF dual-hosted git repository.

nickva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-jiffy.git

commit e48ccda83d4e93b4de47f93ff718148f4bc01013
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Wed Apr 1 15:16:31 2026 -0400

    Improve error handling in dec_number
    
    Use davisp's suggestion and make an explicit label + goto to it.
---
 c_src/decoder.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/c_src/decoder.c b/c_src/decoder.c
index 2a9267b..354c335 100644
--- a/c_src/decoder.c
+++ b/c_src/decoder.c
@@ -443,8 +443,7 @@ dec_number(Decoder* d, ERL_NIF_TERM* value)
                         idx++;
                         break;
                     default:
-                        d->i = idx;
-                        return 0;
+                      goto error;
                 }
                 break;
 
@@ -556,8 +555,7 @@ dec_number(Decoder* d, ERL_NIF_TERM* value)
                         idx++;
                         break;
                     default:
-                        d->i = idx;
-                        return 0;
+                        goto error;
                 }
                 break;
 
@@ -581,8 +579,7 @@ dec_number(Decoder* d, ERL_NIF_TERM* value)
                 break;
 
             default:
-                d->i = idx;
-                return 0;
+                goto error;
         }
     }
 
@@ -632,6 +629,10 @@ parse:
     *value = enif_make_sub_binary(d->env, d->arg, start, d->i - start);
     *value = enif_make_tuple2(d->env, num_type, *value);
     return 1;
+
+error:
+    d->i = idx;
+    return 0;
 }
 
 static ERL_NIF_TERM

Reply via email to