bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/30860] Possible usage of NULL in GAS


From: jacob at jacob dot remcomp.fr
Subject: [Bug gas/30860] Possible usage of NULL in GAS
Date: Fri, 15 Sep 2023 14:06:33 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30860

--- Comment #1 from jacob at jacob dot remcomp.fr ---
FUNCTION: int  relax_segment(struct frag *segment_frag_root,segT segment,int
pass)
FILE: write.c: 2683
   case rs_org:
         {     
           offsetT     target = offset;
           addressT    after;

           if (symbolP) {
           /* Convert from an actual address to an  offset into the section.
Here
            * it is assumed that the section's VMA is zero,and can omit
subtracting 
            * it from the symbol's value to get the address offset. */
                know(S_GET_SEGMENT(symbolP)->vma == 0);
                target += S_GET_VALUE(symbolP) * OCTETS_PER_BYTE;
           }     
           know(fragP->fr_next); // Not active if NDEBUG is defined
           after = fragP->fr_next->fr_address + stretch;
We know that fragP->fr_next CAN BE NULL, since the controlling condition of
this loop (the switch is inside a loop) is:
 for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) {

So, we RELY on fr_next being NULL to stop the loop. But we do not test for this
condition before using it here. As you know tghe "know" construct is NOT active
if NDEBUG is active.
PRPOSED FIX:
Replace "know" by "gas_assert"

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]