Skip to content

Commit 0644b21

Browse files
committed
Update esp_video_init.c
esp_video组件存在数组越界Bug:// 错误的代码(第296-297行) s_sensor_sccb_mask[i2c_port].sccb_io[0] = NULL; s_sensor_sccb_mask[i2c_port].sccb_io[1] = NULL; // ❌ 数组越界! 问题分析: sccb_io 数组大小定义为 ESP_VIDEO_INIT_DEV_NUMS 这是一个枚举值,取决于启用的视频设备数量 您只启用了DVP设备,所以 ESP_VIDEO_INIT_DEV_NUMS = 1 数组只有 sccb_io[0],但代码试图访问 sccb_io[1] GCC的 -Werror=array-bounds 检测到越界访问并报错 🔧 修复内容 // 修复后的代码(第296-298行) s_sensor_sccb_mask[i2c_port].handle = NULL; for (int j = 0; j < ESP_VIDEO_INIT_DEV_NUMS; j++) { s_sensor_sccb_mask[i2c_port].sccb_io[j] = NULL; } 将硬编码的数组访问改为循环: 这样无论 ESP_VIDEO_INIT_DEV_NUMS 的值是多少(1、2、3...),代码都能正确工作。
1 parent 54c9344 commit 0644b21

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

esp_video/src/esp_video_init.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ static void destroy_sccb_device(esp_sccb_io_handle_t handle, esp_video_init_sccb
293293
mark[i2c_port].handle = NULL;
294294

295295
s_sensor_sccb_mask[i2c_port].handle = NULL;
296-
s_sensor_sccb_mask[i2c_port].sccb_io[0] = NULL;
297-
s_sensor_sccb_mask[i2c_port].sccb_io[1] = NULL;
296+
for (int j = 0; j < ESP_VIDEO_INIT_DEV_NUMS; j++) {
297+
s_sensor_sccb_mask[i2c_port].sccb_io[j] = NULL;
298+
}
298299
}
299300
}
300301
} else {

0 commit comments

Comments
 (0)