Skip to content

Currently-harmless UB in stack_reset() and stack_reallocate() #2881

@nicowilliams

Description

@nicowilliams

Reported here.

clang w/ -fsanitize=undefied reports:

../src/exec_stack.h:64:32: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/exec_stack.h:64:32 in
../src/exec_stack.h:83:36: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/exec_stack.h:83:36 in

These are cases doing pointer arithmetic with NULL pointers and then yield NULL pointers. If the compiler were to try to optimize these functions away due to this, then that would cause jq to break immediately -- the tests certainly wouldn't pass, especially with valgrind. Therefore it is safe to say that for all the tested builds of jq this bit of UB is not currently a problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions