Avoid const_cast, static buffer and buffer overlap