From 2701b7d04e86480638906ef30bb454181ca82d8a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 22 Feb 2024 20:13:51 -0500 Subject: [PATCH] Address some gcc-13 analyzer warnings. #33 --- src/file.js.c | 12 ++++++++++++ src/httpd.js.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/file.js.c b/src/file.js.c index eb0eeb78..238c1e3e 100644 --- a/src/file.js.c +++ b/src/file.js.c @@ -452,6 +452,12 @@ static void _file_stat_complete(uv_fs_t* request) void tf_file_stat(tf_task_t* task, const char* path, void (*callback)(tf_task_t* task, const char* path, int result, const uv_stat_t* stat, void* user_data), void* user_data) { + if (!path) + { + callback(task, path, -EINVAL, NULL, user_data); + return; + } + const char* zip = tf_task_get_zip_path(task); size_t path_length = strlen(path) + 1; stat_t* data = tf_malloc(sizeof(stat_t) + path_length); @@ -575,6 +581,12 @@ static void _file_read_after_work(uv_work_t* work, int result) void tf_file_read(tf_task_t* task, const char* path, void (*callback)(tf_task_t* task, const char* path, int result, const void* data, void* user_data), void* user_data) { + if (!path) + { + callback(task, path, -EINVAL, NULL, user_data); + return; + } + size_t path_length = strlen(path) + 1; read_t* data = tf_malloc(sizeof(read_t) + path_length); memset(data, 0, sizeof(read_t)); diff --git a/src/httpd.js.c b/src/httpd.js.c index fa136c81..bd7ba33c 100644 --- a/src/httpd.js.c +++ b/src/httpd.js.c @@ -509,6 +509,11 @@ static void _httpd_endpoint_hitches(tf_http_request_t* request) static const char* _after(const char* text, const char* prefix) { + if (!text || !prefix) + { + return NULL; + } + size_t prefix_length = strlen(prefix); if (strncmp(text, prefix, prefix_length) == 0) {