This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8931

-- gerrit

commit 58ae6d8a17f4c39c3f0798e9df845df7eeaa3b7e
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Thu May 22 02:02:19 2025 +0200

    helper: configuration: check for empty search dirs
    
    The function find_file() is supposed to be called when the search
    dirs in 'script_search_dirs' has already been populated.
    
    This is not the case when the command 'ocd_find' is used in one of
    the embedded scripts 'startup.tcl'. It then triggers SIGSEGV.
    
    Check for 'script_search_dirs' and eventually skip searching in
    the dirs.
    
    Change-Id: I9e75a8739c94de72041fb64487910d60dffcb2bd
    signed-off-by: antonio borneo <borneo.anto...@gmail.com>

diff --git a/src/helper/configuration.c b/src/helper/configuration.c
index 16732eb3dd..447b0dfefa 100644
--- a/src/helper/configuration.c
+++ b/src/helper/configuration.c
@@ -71,17 +71,18 @@ char *find_file(const char *file)
        full_path = alloc_printf("%s", file);
        fp = fopen(full_path, mode);
 
-       while (!fp) {
-               free(full_path);
-               full_path = NULL;
-               dir = *search_dirs++;
+       if (script_search_dirs)
+               while (!fp) {
+                       free(full_path);
+                       full_path = NULL;
+                       dir = *search_dirs++;
 
-               if (!dir)
-                       break;
+                       if (!dir)
+                               break;
 
-               full_path = alloc_printf("%s/%s", dir, file);
-               fp = fopen(full_path, mode);
-       }
+                       full_path = alloc_printf("%s/%s", dir, file);
+                       fp = fopen(full_path, mode);
+               }
 
        if (fp) {
                fclose(fp);

-- 

Reply via email to