Skip to content

feat: max_depth - #8

Open
vird wants to merge 1 commit into
masterfrom
feat/max_depth2
Open

feat: max_depth#8
vird wants to merge 1 commit into
masterfrom
feat/max_depth2

Conversation

@vird

@vird vird commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread c_src/util.c Outdated
return 0;
}

if(!enif_get_uint(env, tuple[1], &depth)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since depth is int should we do enif_get_int and just additionally check depth > 0?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess enif_get_uint already do that
https://erlang.org/documentation/doc-6.1/erts-6.1/doc/html/erl_nif.html#enif_get_uint
Set *ip to the unsigned integer value of term and return true, or return false if term is not an unsigned integer or is outside the bounds of type unsigned int

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, the problem is with the number being outside the signed integer bounds but still inside the unsigned integer bounds. Another fix may be to explicitly assert depth does not exceed INT_MAX. What do you think? In practice, we should not expect such a large depth off course, so it is a nitpick

Comment thread c_src/util.c Outdated
return 0;
}

*max_depth = (int) depth;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue with unsigned vs. signed likely surface here. Worth a check about size of depth, or redefining depth as a signed integer

@vird
vird force-pushed the feat/max_depth2 branch from 4b7ae75 to 82c479d Compare July 22, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants