Hi Anton,

On Wed, 2024-10-23 at 13:40 +0300, ant.v.morya...@gmail.com wrote:
> Fix a bug that caused a null pointer dereference in the `dwarf_ranges` 
> function.
> Added a check for NULL before dereferencing the pointer `d` to prevent 
> potential
> segmentation faults.

Basically the same comments as for the other patch. Please sign your
work and follow the formatting conventions of the existing code.

Also do you have a testcase for this?
I have some trouble seeing how we would at this point with d equal to
NULL. It seems like other guards would prevent us reaching this point.

> ---
>  libdw/dwarf_ranges.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libdw/dwarf_ranges.c b/libdw/dwarf_ranges.c
> index b853e4b9..a4a04761 100644
> --- a/libdw/dwarf_ranges.c
> +++ b/libdw/dwarf_ranges.c
> @@ -532,9 +532,10 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, 
> Dwarf_Addr *basep,
>                                    secidx, offset, 1))
>       return -1;
>      }
> -
> -  readp = d->d_buf + offset;
> -  readendp = d->d_buf + d->d_size;
> +  if(d != NULL){
> +     readp = d->d_buf + offset;
> +     readendp = d->d_buf + d->d_size;
> +  }
>  
>    Dwarf_Addr begin;
>    Dwarf_Addr end;

Thanks,

Mark

Reply via email to