Rémi Bernon (@rbernon) commented about dlls/windows.web/json_value.c:
- return (!in_string && !curly_brackets && !square_brackets && !expect_value) ? S_OK : WEB_E_INVALID_JSON_STRING;
+}
+static HRESULT trim_string( HSTRING input, const WCHAR *string_to_remove, HSTRING *trimmed_string ) +{
- HSTRING pattern = NULL, new_string = NULL;
- HRESULT hr = WindowsCreateString( string_to_remove, wcslen( string_to_remove ), &pattern );
- if (SUCCEEDED(hr)) hr = WindowsTrimStringStart( input, pattern, &new_string );
- if (SUCCEEDED(hr)) hr = WindowsTrimStringEnd( new_string, pattern, &new_string );
- if (SUCCEEDED(hr)) hr = WindowsDuplicateString( new_string, trimmed_string );
- WindowsDeleteString( pattern );
- WindowsDeleteString( new_string );
- return hr;
You're leaking some references here, I think you don't need the last `WindowsDuplicateString` and this should work as well:
``` HSTRING pattern = NULL, new_string = NULL; HRESULT hr = WindowsCreateString( string_to_remove, wcslen( string_to_remove ), &pattern );
if (SUCCEEDED(hr)) hr = WindowsTrimStringStart( input, pattern, &new_string ); if (SUCCEEDED(hr)) hr = WindowsTrimStringEnd( new_string, pattern, trimmed_string );
WindowsDeleteString( pattern ); WindowsDeleteString( tmp ); return hr; ```