Re: ubitx #v6 Screen Speed Mod #v6

Jack, W8TEE

You're wrong and it's still not safe. When globals are initialized at their global definition, they are only initialized once at load time. So, when you call the frequency format routine the first time (e.g., 7123456), all works as it should. Now call it the second time with the new frequency 21123456. Now b[] has:


but it still works because you over-allocated buffer space. Each time you call it, however, you extend the string. Eventually, on the 5th call, you will overflow the string space and all bets are off. This can be one of those test-it-three-times-and-it's-okay bugs that are difficult to find because the stack is usually blow away when the bug finally manifests itself.

If you're really worried about the few bytes used by memset(), why the hell are you using a 30-byte buffer space when 9 will work? Using the smaller buffer space would have produced the error for you and the second call. However, because it's a memory-overwrite, you still may not even know it's happened.

Jack, W8TEE

On Friday, January 17, 2020, 12:23:03 PM EST, Gary Anderson <gary.ag5tx@...> wrote:

Thanks Jack and Reed.
When I created the global buffers in my test code:
char b[30] = {'\0'};
char c[30] = {'\0'};
The function is only called with initialized buffers from what I saw in a quick look at the V6 code.

Jack, W8TEE

Join to automatically receive all group messages.