# createWindowsEnvBlock: Reduce NUL terminator count to only what's required · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/423761bb6de68bec9482dbc3b3c21b2b5c74a2b9)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 423761bb6de68bec9482dbc3b3c21b2b5c74a2b9

Requested commit: 423761bb6de68bec9482dbc3b3c21b2b5c74a2b9

Commit: 423761bb6de68bec9482dbc3b3c21b2b5c74a2b9

Tree: 62b4db263493430c1966e16851c020e558c832f5

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
createWindowsEnvBlock: Reduce NUL terminator count to only what's required

This code previously added 4 NUL code units, but that was likely due to a misinterpretation of this part of the CreateProcess documentation:

> A Unicode environment block is terminated by four zero bytes: two for the last string, two more to terminate the block.

(four zero *bytes* means *two* zero code units)

Additionally, the second zero code unit is only actually needed when the environment is empty due to a quirk of the CreateProcess implementation. In the case of a non-empty environment, there always ends up being two trailing NUL code units since one will come after the last environment variable in the block.

```

## Parents

- [2a4e06bcb30f71e83b14026bcbade6aac3aece84](https://git.cafe/gitcafe/zig/commit/2a4e06bcb30f71e83b14026bcbade6aac3aece84?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/423761bb6de68bec9482dbc3b3c21b2b5c74a2b9?format=markdown)
