fix compiler warnings and release mode u32 overflow

This commit is contained in:
asrael 2025-11-10 09:59:42 -06:00
parent 9550d34e65
commit 704b14b2a0
3 changed files with 12 additions and 7 deletions

View file

@ -18,7 +18,7 @@ struct pxl8_script {
pxl8_gfx* gfx;
pxl8_input_state* input;
pxl8_ui* ui;
char last_error[1024];
char last_error[2048];
char main_path[256];
char watch_dir[256];
time_t latest_mod_time;
@ -56,7 +56,7 @@ static void pxl8_script_repl_promote_locals(const char* input, char* output, siz
if (!in_string && input[i] == '(' &&
strncmp(&input[i], "(local ", 7) == 0) {
strncpy(&output[j], "(global ", 8);
memcpy(&output[j], "(global ", 8);
j += 8;
i += 7;
continue;
@ -847,8 +847,10 @@ static void* pxl8_script_repl_stdin_thread(void* user_data) {
u32 next_tail = (repl->tail + 1) % PXL8_REPL_RING_BUFFER_SIZE;
if (next_tail != repl->head) {
strncpy(repl->ring_buffer[repl->tail].buffer, repl->accumulator, PXL8_MAX_REPL_COMMAND_SIZE - 1);
repl->ring_buffer[repl->tail].buffer[PXL8_MAX_REPL_COMMAND_SIZE - 1] = '\0';
size_t len = strlen(repl->accumulator);
size_t copy_len = len < PXL8_MAX_REPL_COMMAND_SIZE - 1 ? len : PXL8_MAX_REPL_COMMAND_SIZE - 1;
memcpy(repl->ring_buffer[repl->tail].buffer, repl->accumulator, copy_len);
repl->ring_buffer[repl->tail].buffer[copy_len] = '\0';
repl->tail = next_tail;
repl->waiting_for_eval = true;