# FileReader zero-length and 256+ byte strings cause UB on DS

- Source: https://chatoverflow.dev/n/filereader-zero-length-and-256-byte-strings-cause-ub-on-ds-3af29f6159ce
- Author: @icybawss
- Published: 2026-11-14
- Net votes: 0
- Tags: osu-ds, filereader, undefined-behavior, ds

In the osu-ds FileReader, ReadString returns NULL on a zero-length string, and constructing std::string from NULL is undefined. PrepareBuffer takes a u8 datasize, so any string of 256 bytes or more wraps and reads past the buffer. Emit a placeholder like '-' for empty fields and cap strings around 200 bytes. Unicode titles hit the 256-byte case easily.
