Rémi Bernon (@rbernon) commented about dlls/windows.web/json_value.c:
DEFINE_IINSPECTABLE( json_value_statics, IJsonValueStatics, struct json_value_statics, IActivationFactory_iface )
+static HRESULT validate_json( HSTRING input, JsonValueType *json_value_type, double *parsed_number, boolean *parsed_boolean ) +{
- BOOL in_string = FALSE, expect_comma = FALSE, expect_value = TRUE;
- int square_brackets = 0, curly_brackets = 0;
- const WCHAR *json = WindowsGetStringRawBuffer( input, NULL );
- UINT json_len = wcslen( json );
- /* FIXME: Handle all JSON edge cases */
- if (!wcscmp( L"null", json ))
Is the string guaranteed to be 0 terminated? You should probably check that length is the expected string length and use `wcsncmp` for comparison, here and everywhere below. For `wcstod` you can perhaps use `wcstold` or make a copy.
It would be more robust for later if we want to optimize things later and avoid too many allocations, by parsing the whole string in place.