The search for the topic's null terminator was starting from the beginning of the payload, rather than after the sender's null terminator
The topic slice was also starting from the beginning of the payload
The i cursor was getting an extra +1, presumably to skip the null bytes for both the sender and the topic, even though the sender's byte was already being skipped a couple of lines down
Now, the sender null byte is skipped earlier for clarity and the search/slice for the topic starts in the right place.
There were a few things wrong here:
i
cursor was getting an extra+1
, presumably to skip the null bytes for both the sender and the topic, even though the sender's byte was already being skipped a couple of lines downNow, the sender null byte is skipped earlier for clarity and the search/slice for the topic starts in the right place.