commit 390befe9cf0a9a1780b225c07ce0960bf22da01a from: p2r3 date: Mon Sep 1 19:28:38 2025 UTC fix potentially uninitialized pointers commit - b20c9f508f8cc9f078408742d0df1085dff07619 commit + 390befe9cf0a9a1780b225c07ce0960bf22da01a blob - bfaaaaf229820e4964b9e9467df9afb91829881b blob + f0bbe086ad4cb06de27d563e9f74cc7656da4560 --- src/procedures.c +++ src/procedures.c @@ -1086,13 +1086,14 @@ void handlePlayerUseItem (PlayerData *player, short x, #ifdef ALLOW_CHESTS else if (target == B_chest) { // Get a pointer to the entry following this chest in block_changes - uint8_t *storage_ptr; + uint8_t *storage_ptr = NULL; for (int i = 0; i < block_changes_count; i ++) { if (block_changes[i].block != B_chest) continue; if (block_changes[i].x != x || block_changes[i].y != y || block_changes[i].z != z) continue; storage_ptr = (uint8_t *)(&block_changes[i + 1]); break; } + if (storage_ptr == NULL) return; // Terrible memory hack!! // Copy the pointer into the player's crafting table item array. // This allows us to save some memory by repurposing a feature that @@ -1497,7 +1498,7 @@ void handleServerTick (int64_t time_since_last_tick) { } // Find the player closest to this mob - PlayerData* closest_player; + PlayerData* closest_player = &player_data[0]; uint32_t closest_dist = 2147483647; for (int j = 0; j < MAX_PLAYERS; j ++) { if (player_data[j].client_fd == -1) continue;