File tree Expand file tree Collapse file tree 5 files changed +52
-3
lines changed
src/ArduinoJson/Deserialization Expand file tree Collapse file tree 5 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ ArduinoJson: change log
4
4
HEAD
5
5
----
6
6
7
+ * Fixed ` deserializeJson() ` silently accepting a ` Stream* ` (issue #978 )
7
8
* Fixed invalid result from ` operator| ` (issue #981 )
8
9
9
10
> ### BREAKING CHANGE
Original file line number Diff line number Diff line change @@ -17,4 +17,4 @@ before_build:
17
17
build_script :
18
18
- cmake --build . --config %CONFIGURATION%
19
19
test_script :
20
- - ctest --output-on-failure .
20
+ - ctest -C %CONFIGURATION% - -output-on-failure .
Original file line number Diff line number Diff line change 6
6
7
7
namespace ARDUINOJSON_NAMESPACE {
8
8
9
+ template <typename T>
10
+ struct IsCharOrVoid {
11
+ static const bool value =
12
+ is_same<T, void >::value || is_same<T, char >::value ||
13
+ is_same<T, unsigned char >::value || is_same<T, signed char >::value;
14
+ };
15
+
16
+ template <typename T>
17
+ struct IsCharOrVoid <const T> : IsCharOrVoid<T> {};
18
+
9
19
class UnsafeCharPointerReader {
10
20
const char * _ptr;
11
21
@@ -41,12 +51,16 @@ class SafeCharPointerReader {
41
51
};
42
52
43
53
template <typename TChar>
44
- inline UnsafeCharPointerReader makeReader (TChar* input) {
54
+ inline typename enable_if<IsCharOrVoid<TChar>::value,
55
+ UnsafeCharPointerReader>::type
56
+ makeReader (TChar* input) {
45
57
return UnsafeCharPointerReader (reinterpret_cast <const char *>(input));
46
58
}
47
59
48
60
template <typename TChar>
49
- inline SafeCharPointerReader makeReader (TChar* input, size_t n) {
61
+ inline
62
+ typename enable_if<IsCharOrVoid<TChar>::value, SafeCharPointerReader>::type
63
+ makeReader (TChar* input, size_t n) {
50
64
return SafeCharPointerReader (reinterpret_cast <const char *>(input), n);
51
65
}
52
66
Original file line number Diff line number Diff line change @@ -13,3 +13,24 @@ add_executable(MiscTests
13
13
14
14
target_link_libraries (MiscTests catch )
15
15
add_test (Misc MiscTests )
16
+
17
+
18
+ add_executable (Issue978
19
+ Issue978.cpp
20
+ )
21
+ set_target_properties (Issue978
22
+ PROPERTIES
23
+ EXCLUDE_FROM_ALL TRUE
24
+ EXCLUDE_FROM_DEFAULT_BUILD TRUE
25
+ )
26
+ add_test (
27
+ NAME
28
+ Issue978
29
+ COMMAND
30
+ ${CMAKE_COMMAND} --build . --target Issue978 --config $< CONFIGURATION>
31
+ WORKING_DIRECTORY
32
+ ${CMAKE_BINARY_DIR}
33
+ )
34
+ set_tests_properties (Issue978
35
+ PROPERTIES
36
+ WILL_FAIL TRUE )
Original file line number Diff line number Diff line change
1
+ // ArduinoJson - arduinojson.org
2
+ // Copyright Benoit Blanchon 2014-2019
3
+ // MIT License
4
+
5
+ #include < ArduinoJson.h>
<
5C9F
/td>6
+
7
+ struct Stream {};
8
+
9
+ int main () {
10
+ Stream* stream = 0 ;
11
+ DynamicJsonDocument doc (1024 );
12
+ deserializeJson (doc, stream);
13
+ }
You can’t perform that action at this time.
0 commit comments