From 49ecd1a2b66359961ffa8cbbe5a6f12da6aa46dd Mon Sep 17 00:00:00 2001 From: Bond Keevil Date: Fri, 9 Aug 2019 22:40:22 -0400 Subject: [PATCH] Fix Issue 102, missing null check in index_handler() (#103) --- .../single_chip/camera_web_server/main/app_httpd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/single_chip/camera_web_server/main/app_httpd.c b/examples/single_chip/camera_web_server/main/app_httpd.c index fd5145f..3e9273f 100644 --- a/examples/single_chip/camera_web_server/main/app_httpd.c +++ b/examples/single_chip/camera_web_server/main/app_httpd.c @@ -648,10 +648,16 @@ static esp_err_t index_handler(httpd_req_t *req){ httpd_resp_set_type(req, "text/html"); httpd_resp_set_hdr(req, "Content-Encoding", "gzip"); sensor_t * s = esp_camera_sensor_get(); - if (s->id.PID == OV3660_PID) { - return httpd_resp_send(req, (const char *)index_ov3660_html_gz_start, index_ov3660_html_gz_len); + if (s != NULL) { + if (s->id.PID == OV3660_PID) { + return httpd_resp_send(req, (const char *)index_ov3660_html_gz_start, index_ov3660_html_gz_len); + } else { + return httpd_resp_send(req, (const char *)index_ov2640_html_gz_start, index_ov2640_html_gz_len); + } + } else { + ESP_LOGE(TAG,"Camera sensor not found"); + return httpd_resp_send_500(req); } - return httpd_resp_send(req, (const char *)index_ov2640_html_gz_start, index_ov2640_html_gz_len); } void app_httpd_main(){