Skip to content

oss-fuzz/issues/detail?id=68056 #3148

@pkoppstein

Description

@pkoppstein

Describe the bug

OSS-FUZZ is unhappy with a filter that uses _nwise(0).

Note that _nwise(0) typically behaves like recurse([]), and one could argue that the def of _nwise/1
is just fine. If the current behavior is judged to be acceptable, what should be done about 68056?

To Reproduce

[1] | _nwise(0)

Expected behavior
If the current behavior is deemed unsatisfactory, how should the def be altered?
Plausible alternatives would include:

def _nwise($n):
  def n: if length <= $n then . else .[0:$n] , (.[$n:] | n) end;
  if $n <= 0 then empty
  else n
  end;

and similar alternatives, e.g. replacing empty above with a call to error.
(Since the guard is outside def n, the performance impact would be negligible.)

Additional context
Neither gojq nor jaq define _nwise/1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions