[前][次][番号順一覧][スレッド一覧]

ruby-changes:73971

From: Aaron <ko1@a...>
Date: Thu, 13 Oct 2022 01:56:33 +0900 (JST)
Subject: [ruby-changes:73971] 107531583c (master): Unwrap shape id as unsigned int

https://git.ruby-lang.org/ruby.git/commit/?id=107531583c

From 107531583c8e8b2d706a6a27f46d429e387efff7 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Wed, 12 Oct 2022 08:54:02 -0700
Subject: Unwrap shape id as unsigned int

Shape IDs are unsigned.  This commit unwraps the shape id as an unsigned
int, which will automatically raise an argument error and also eliminate
a compilation warning.
---
 shape.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/shape.c b/shape.c
index 80d135b897..f21b9a4ece 100644
--- a/shape.c
+++ b/shape.c
@@ -514,8 +514,8 @@ rb_shape_flags_mask(void) https://github.com/ruby/ruby/blob/trunk/shape.c#L514
 static VALUE
 rb_shape_find_by_id(VALUE mod, VALUE id)
 {
-    shape_id_t shape_id = NUM2INT(id);
-    if (shape_id < 0 || shape_id >= GET_VM()->next_shape_id) {
+    shape_id_t shape_id = NUM2UINT(id);
+    if (shape_id >= GET_VM()->next_shape_id) {
         rb_raise(rb_eArgError, "Shape ID %d is out of bounds\n", shape_id);
     }
     return rb_shape_t_to_rb_cShape(rb_shape_get_shape_by_id(shape_id));
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]