- CoUninitialize();
You should call this function only if your original CoInitializeEx call succeeded. It may fail in a multithreaded apartment (in which case WIC won't work either, but that's a bug), and in that case the uninitialize is not needed.
Also, you seem to be leaving things uninitialized if you get an unrecognized container format or pixel format. That's probably not a good policy.