# Extended 4.6 — src/win/winDebug.c: fopen() return unchecked in crash handler

Bug ref      : pharo.md §4.6
Severity     : MEDIUM (crash handler itself SEGVs when CWD isn't writable)
File         : src/win/winDebug.c
Lines (HEAD) : 138-167 (`printCrashDebugInformation`)

## Problem

```c
crashDumpFile = fopen(crashdumpFileName, "a+");
vm_setVMOutputStream(crashDumpFile);

reportStackState(exp, date, crashDumpFile);
...
vm_setVMOutputStream(stderr);
fclose(crashDumpFile);
```

`fopen` can return NULL when the CWD or `crash.dmp` is not
writable. The subsequent `reportStackState` and `fclose` then run
on NULL, masking the original crash with a second one.

The Unix counterpart in `debugUnix.c:60-69` already null-checks.
This brings Windows to parity.

## Fix

```diff
diff --git a/src/win/winDebug.c b/src/win/winDebug.c
index 866ca6708..817fce191 100644
--- a/src/win/winDebug.c
+++ b/src/win/winDebug.c
@@ -159,12 +159,12 @@ EXPORT(void) printCrashDebugInformation(LPEXCEPTION_POINTERS exp){
 	crashdumpFileName[0] = 0;
 	getCrashDumpFilenameInto(crashdumpFileName);
 	crashDumpFile = fopen(crashdumpFileName, "a+");
-	vm_setVMOutputStream(crashDumpFile);
-
-	reportStackState(exp, date, crashDumpFile);
-
-	vm_setVMOutputStream(stderr);
-	fclose(crashDumpFile);
+	if (crashDumpFile != NULL) {
+		vm_setVMOutputStream(crashDumpFile);
+		reportStackState(exp, date, crashDumpFile);
+		vm_setVMOutputStream(stderr);
+		fclose(crashDumpFile);
+	}
 
 	reportStackState(exp, date, stderr);
 	fflush(stdout);

```

## Test plan

- Run the VM from a read-only CWD; trigger a crash. Before:
  printCrashDebugInformation SEGVs in `vm_setVMOutputStream(NULL)`
  → `fflush(NULL)`. After: report is written to stderr only, no
  secondary SEGV.
- Normal crash: dump file written as before.

## Risk notes

- The Unix counterpart handles this; bringing Windows in line.
- `reportStackState(exp, date, stderr)` still runs so the operator
  sees the crash report on stderr at minimum.
