CJSONVariantWriter: fix possible NULL pointer dereferencing