Page MenuHome

BLF: Reduction of use of BLF_DRAW_STR_DUMMY_MAX
ClosedPublic

Authored by Harley Acheson (harley) on Jan 11 2022, 1:26 AM.

Details

Summary

Reduction of the number of uses of the define BLF_DRAW_STR_DUMMY_MAX
by using actual sizes of static character arrays.


BLF_DRAW_STR_DUMMY_MAX (1024) is used 54 times as a maximum string length. But in half (27) of the uses the actual size of the character array is known and is less than this amount. The maximum argument is there for safety. Operations will stop when the terminating zero is hit or the maximum length is reached. But in these cases this maximum is beyond the allocated memory size so will cause buffer overflow if the string is not null-terminated.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Jan 11 2022, 1:26 AM
Harley Acheson (harley) created this revision.

Some repetition can be avoided using STRNCPY_RLEN, SNPRINTF_RLEN. No extra review iteration is needed for this though.

This revision is now accepted and ready to land.Jan 11 2022, 5:45 AM

Removing some duplication by use of macros SNPRINTF and SNPRINTF_RLEN