Checking the return value of CryptAcquireContextW() is also possible but I took the path of minimal change in the source.
The change I suggest would be small too.
Besides, I consider passing pointers to uninitialized variables a bad programming practice.
Not when they're out pointers. --Juan