# A08 — pathUtilities: NULL guard tests wrong variable

Bug ref      : always.md A.8 ; pharo.md §4.2
Severity     : HIGH (crash on every dot-less directory entry, e.g. Makefile)
File         : src/pathUtilities.c
Lines (HEAD) : 230-243 (POSIX `vm_path_find_files_with_extension_in_folder`)

## Problem

```
char *fileExtension = strrchr(name, '.');
if(!extension)
    continue;
if(strcmp(fileExtension, extension) != 0)
    continue;
```

The NULL guard tests `extension` (the function parameter, always
non-NULL) instead of `fileExtension` (the local that `strrchr` may
return as NULL). Any directory entry without a `.` (e.g. `Makefile`,
`README`, `LICENSE`) feeds NULL into `strcmp` and segfaults.

This is reached during normal Pharo VM startup whenever
`vm_path_find_files_with_extension_in_folder` is run over a directory
that contains files without a dot — which is essentially every
directory.

## Fix

Test the variable that was just assigned.

```diff
--- a/src/pathUtilities.c
+++ b/src/pathUtilities.c
@@ -230,7 +230,7 @@ vm_path_find_files_with_extension_in_folder(const char *searchPath, const char *
     while((entry = readdir(dir)) != NULL)
     {
         char *name = entry->d_name;
         char *fileExtension = strrchr(name, '.');
-        if(!extension)
+        if(!fileExtension)
             continue;
 
         if(strcmp(fileExtension, extension) != 0)

```

## Test plan

- Create a directory containing `foo.image`, `Makefile`, `README`.
- Run `vm_path_find_files_with_extension_in_folder(dir, ".image", ...)`.
- Before: SIGSEGV.  After: returns the single `.image` match.

## Risk

The previous guard was dead code (parameter is checked at higher
levels and is never NULL in practice). Replacing it with the correct
guard is strictly safer.
