@@ -2786,42 +2786,42 @@ bool HandleFileObstruction(EvalContext *ctx, const char *path, const struct stat
27862786 return false;
27872787 }
27882788
2789- // The following dereferences are protected by the null checks above,
2790- // but we add explicit assertions for static analysis tools
2791- assert ( sb != NULL );
2792- assert ( attr != NULL );
2789+ // Use local variables to help static analysis tools understand that
2790+ // the pointers have been checked for NULL before dereferencing
2791+ const struct stat * const safe_sb = sb ; // Explicit alias after null check
2792+ const Attributes * const safe_attr = attr ; // Explicit alias after null check
27932793
2794- const mode_t st_mode = sb -> st_mode ;
2795- const bool move_obstructions = attr -> move_obstructions ;
2794+ const mode_t st_mode = safe_sb -> st_mode ;
2795+ const bool move_obstructions = safe_attr -> move_obstructions ;
27962796
27972797 // If path exists, but is not a regular file, it's an obstruction
27982798 if (!S_ISREG (st_mode ))
27992799 {
28002800 if (move_obstructions )
28012801 {
2802- if (MakingChanges (ctx , pp , attr , result , "move obstruction '%s'" , path ))
2802+ if (MakingChanges (ctx , pp , safe_attr , result , "move obstruction '%s'" , path ))
28032803 {
28042804 char backup [CF_BUFSIZE ];
28052805 snprintf (backup , sizeof (backup ), "%s.cf-moved" , path );
28062806
28072807 if (rename (path , backup ) == -1 )
28082808 {
2809- RecordFailure (ctx , pp , attr , "Could not move obstruction '%s' to '%s'. (rename: %s)" ,
2809+ RecordFailure (ctx , pp , safe_attr , "Could not move obstruction '%s' to '%s'. (rename: %s)" ,
28102810 path , backup , GetErrorStr ());
28112811 * result = PromiseResultUpdate (* result , PROMISE_RESULT_FAIL );
28122812 return false;
28132813 }
28142814 else
28152815 {
2816- RecordChange (ctx , pp , attr , "Moved obstructing path '%s' to '%s'" , path , backup );
2816+ RecordChange (ctx , pp , safe_attr , "Moved obstructing path '%s' to '%s'" , path , backup );
28172817 * result = PromiseResultUpdate (* result , PROMISE_RESULT_CHANGE );
28182818 return true;
28192819 }
28202820 }
28212821 }
28222822 else if (!S_ISLNK (st_mode ))
28232823 {
2824- RecordFailure (ctx , pp , attr , "Path '%s' is not a regular file and move_obstructions is not set" , path );
2824+ RecordFailure (ctx , pp , safe_attr , "Path '%s' is not a regular file and move_obstructions is not set" , path );
28252825 * result = PromiseResultUpdate (* result , PROMISE_RESULT_FAIL );
28262826 return false;
28272827 }
0 commit comments