mruby-hash-ext/hash.c (hash_values_at): early return from the function.
authorYukihiro "Matz" Matsumoto <[email protected]>
Fri, 21 Oct 2022 04:41:38 +0000 (21 13:41 +0900)
committerYukihiro "Matz" Matsumoto <[email protected]>
Fri, 21 Oct 2022 04:41:38 +0000 (21 13:41 +0900)
mrbgems/mruby-hash-ext/src/hash-ext.c

index 9c85858..b634373 100644 (file)
@@ -29,6 +29,7 @@ hash_values_at(mrb_state *mrb, mrb_value hash)
 
   mrb_get_args(mrb, "*", &argv, &argc);
   result = mrb_ary_new_capa(mrb, argc);
+  if (argc == 0) return result;
   ai = mrb_gc_arena_save(mrb);
   for (i = 0; i < argc; i++) {
     mrb_ary_push(mrb, result, mrb_hash_get(mrb, hash, argv[i]));