Immediate-Mode-UI / Immediate-Mode-UI/Nuklear

nk_begin_titled/nk_font_atlas_add_from_file segfault

Open
#241 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
11.4k
Forks
686
Avg merge
4d 1h
Merged PRs (30d)
3

Description

nk_font_atlas_add_from_file can induce a segfault in nk_begin_titled if the font file is not found.

Specifically here, ctx->style.font exists (but is invalid) so ctx->style.font->width causes segfault. (nk_begin_titled, about ~19965)

NK_ASSERT(ctx->style.font && ctx->style.font->width && "if this triggers you forgot to add a font");

You could probably solve this by checking &size (nk_font_atlas_add_from_file, about ~17303):
memory = nk_file_load(file_path, &size, &atlas->permanent);

Contributor guide

Open the contributing guide

Research direction

Start with nk_font_atlas_add_from_file around the nk_file_load call near ~17303, then trace how its size result affects ctx->style.font in nk_begin_titled around ~19965. Reproduce the missing-font case and verify that it no longer reaches ctx->style.font->width with an invalid font; preserve the existing assertion for genuinely missing fonts.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.