Skip to content

Commit cdd17f5

Browse files
committed
SF Bug 599
SF Bug pocoproject#599 JSON::Array and JSON::Object size() member can implicitly lose precision https://sourceforge.net/p/poco/patches/120/
1 parent a54c34e commit cdd17f5

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎JSON/include/Poco/JSON/Array.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Object;
5757
class JSON_API Array
5858
{
5959
public:
60-
typedef std::vector<Dynamic::Var> ValueVector;
60+
typedef std::vector<Dynamic::Var> ValueVec;
6161
typedef SharedPtr<Array> Ptr;
6262

6363
Array();
@@ -69,10 +69,10 @@ class JSON_API Array
6969
virtual ~Array();
7070
/// Destructor
7171

72-
ValueVector::const_iterator begin() const;
72+
ValueVec::const_iterator begin() const;
7373
/// Returns iterator
7474

75-
ValueVector::const_iterator end() const;
75+
ValueVec::const_iterator end() const;
7676
/// Returns iterator
7777

7878
Dynamic::Var get(unsigned int index) const;
@@ -148,26 +148,26 @@ class JSON_API Array
148148
/// Removes the element on the given index.
149149

150150
private:
151-
ValueVector _values;
151+
ValueVec _values;
152152
};
153153

154154

155-
inline Array::ValueVector::const_iterator Array::begin() const
155+
inline Array::ValueVec::const_iterator Array::begin() const
156156
{
157157
return _values.begin();
158158
}
159159

160160

161-
inline Array::ValueVector::const_iterator Array::end() const
161+
inline Array::ValueVec::const_iterator Array::end() const
162162

163163
{
164164
return _values.end();
165165
}
166166

167167

168-
inline unsigned int Array::size() const
168+
inline std::size_t Array::size() const
169169
{
170-
return _values.size();
170+
return static_cast<std::size_t>(_values.size());
171171
}
172172

173173

‎JSON/include/Poco/JSON/Object.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ inline void Object::set(const std::string& key, const Dynamic::Var& value)
186186
}
187187

188188

189-
inline unsigned int Object::size() const
189+
inline std::size_t Object::size() const
190190
{
191-
return _values.size();
191+
return static_cast<std::size_t>(_values.size());
192192
}
193193

194194

‎JSON/src/Array.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void Array::stringify(std::ostream& out, unsigned int indent) const
115115
if ( indent > 0 )
116116
out << std::endl;
117117

118-
for(ValueVector::const_iterator it = _values.begin(); it != _values.end();)
118+
for(ValueVec::const_iterator it = _values.begin(); it != _values.end();)
119119
{
120120
for(int i = 0; i < indent; i++)
121121
{

0 commit comments

Comments
 (0)