]> granicus.if.org Git - gc/commitdiff
Eliminate UBSan warning of overflow during descr subtraction in mark_from
authorIvan Maidanski <ivmai@mail.ru>
Thu, 14 Dec 2017 21:54:04 +0000 (00:54 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 14 Dec 2017 21:54:04 +0000 (00:54 +0300)
There is no unsigned overflow because descr has a negative value
actually when it is subtracted from type_descr.

* mark.c (GC_mark_from): Cast descr to signed_word
in (type_descr-(descr+...)).

mark.c

diff --git a/mark.c b/mark.c
index 1da4a1428bbe010550b7c9d6542bae24e33c4a9b..705c4a41312e398abc3777ee145a2e6dee033c82 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -803,8 +803,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
                 continue;
             }
             descr = *(word *)(type_descr
-                              - (descr + (GC_INDIR_PER_OBJ_BIAS
-                                          - GC_DS_PER_OBJECT)));
+                              - ((signed_word)descr + (GC_INDIR_PER_OBJ_BIAS
+                                                       - GC_DS_PER_OBJECT)));
           }
           if (0 == descr) {
               /* Can happen either because we generated a 0 descriptor  */