Commit cf5e25a9 authored by Juha Reunanen's avatar Juha Reunanen Committed by Davis E. King
Browse files

Problem: integer overflow when calculating sizes (may happen e.g. with very large images) (#1148)

* Problem: integer overflow when calculating sizes (may happen e.g. with very large images)
Solution: change some types from (unsigned) long to size_t

# Conflicts:
#	dlib/dnn/tensor.h

* Fix the fact that std::numeric_limits<unsigned long>::max() isn't always the same number

* Revert serialization changes

* Review fix: use long long instead of size_t

* From long to long long all the way

* Change more types to (hopefully) make the compiler happy

* Change many more types to size_t

* Change even more types to size_t

* Minor type changes
parent 1cf6dbf4
......@@ -100,7 +100,7 @@ namespace dlib
);
// functions from the enumerable interface
inline unsigned long size (
inline size_t size (
) const;
inline bool at_start (
......@@ -328,7 +328,7 @@ namespace dlib
typename hash_table,
typename mem_manager
>
unsigned long hash_map_kernel_1<domain,range,expnum,hash_table,mem_manager>::
size_t hash_map_kernel_1<domain,range,expnum,hash_table,mem_manager>::
size (
) const
{
......
......@@ -85,7 +85,7 @@ namespace dlib
);
// functions from the enumerable interface
inline unsigned long size (
inline size_t size (
) const;
inline bool at_start (
......@@ -266,7 +266,7 @@ namespace dlib
typename hash_table,
typename mem_manager
>
unsigned long hash_set_kernel_1<T,expnum,hash_table,mem_manager>::
size_t hash_set_kernel_1<T,expnum,hash_table,mem_manager>::
size (
) const
{
......
......@@ -145,7 +145,7 @@ namespace dlib
);
// functions from the enumerable interface
inline unsigned long size (
inline size_t size (
) const;
bool at_start (
......@@ -336,7 +336,7 @@ namespace dlib
typename mem_manager,
typename compare
>
unsigned long hash_table_kernel_1<domain,range,mem_manager,compare>::
size_t hash_table_kernel_1<domain,range,mem_manager,compare>::
size(
) const
{
......
......@@ -116,7 +116,7 @@ namespace dlib
);
// functions from the enumerable interface
inline unsigned long size (
inline size_t size (
) const;
inline bool at_start (
......@@ -266,7 +266,7 @@ namespace dlib
typename mem_manager,
typename compare
>
unsigned long hash_table_kernel_2<domain,range,bst_base,mem_manager,compare>::
size_t hash_table_kernel_2<domain,range,bst_base,mem_manager,compare>::
size(
) const
{
......
......@@ -55,7 +55,7 @@ namespace dlib
const image_type& img
);
inline unsigned long size (
inline size_t size (
) const;
inline long nr (
......@@ -280,7 +280,7 @@ namespace dlib
typename feature_extractor,
typename hash_function_type
>
unsigned long binned_vector_feature_image<feature_extractor,hash_function_type>::
size_t binned_vector_feature_image<feature_extractor,hash_function_type>::
size (
) const
{
......
......@@ -132,7 +132,7 @@ namespace dlib
operator() as defined below.
!*/
unsigned long size (
size_t size (
) const;
/*!
ensures
......
......@@ -73,8 +73,8 @@ namespace dlib
inline void unload(
) { clear(); }
inline unsigned long size (
) const { return static_cast<unsigned long>(nr()*nc()); }
inline size_t size (
) const { return static_cast<size_t>(nr()*nc()); }
inline long nr (
) const { return num_block_rows; }
......
......@@ -132,7 +132,7 @@ namespace dlib
Both sequence 1 and sequence 2 should have the same effect on H.
!*/
inline unsigned long size (
inline size_t size (
) const;
/*!
ensures
......
......@@ -56,7 +56,7 @@ namespace dlib
const image_type& img
);
inline unsigned long size (
inline size_t size (
) const;
inline long nr (
......@@ -325,7 +325,7 @@ namespace dlib
typename feature_extractor,
typename hash_function_type
>
unsigned long hashed_feature_image<feature_extractor,hash_function_type>::
size_t hashed_feature_image<feature_extractor,hash_function_type>::
size (
) const
{
......
......@@ -125,7 +125,7 @@ namespace dlib
operator() as defined below.
!*/
unsigned long size (
size_t size (
) const;
/*!
ensures
......
......@@ -89,8 +89,8 @@ namespace dlib
inline void unload(
) { clear(); }
inline unsigned long size (
) const { return static_cast<unsigned long>(nr()*nc()); }
inline size_t size (
) const { return static_cast<size_t>(nr()*nc()); }
inline long nr (
) const { return num_block_rows; }
......
......@@ -188,7 +188,7 @@ namespace dlib
Both sequence 1 and sequence 2 should have the same effect on H.
!*/
inline unsigned long size (
inline size_t size (
) const;
/*!
ensures
......
......@@ -53,7 +53,7 @@ namespace dlib
const image_type& img
);
inline unsigned long size (
inline size_t size (
) const;
inline long nr (
......@@ -250,7 +250,7 @@ namespace dlib
template <
typename feature_extractor
>
unsigned long nearest_neighbor_feature_image<feature_extractor>::
size_t nearest_neighbor_feature_image<feature_extractor>::
size (
) const
{
......
......@@ -102,7 +102,7 @@ namespace dlib
operator() as defined below.
!*/
inline unsigned long size (
inline size_t size (
) const;
/*!
ensures
......
......@@ -193,7 +193,7 @@ namespace dlib
num_cols = 0;
}
inline unsigned long size (
inline size_t size (
) const { return static_cast<unsigned long>(nr()*nc()); }
inline long nr (
......
......@@ -197,7 +197,7 @@ namespace dlib
Both sequence 1 and sequence 2 should have the same effect on H.
!*/
inline unsigned long size (
inline size_t size (
) const;
/*!
ensures
......
......@@ -104,7 +104,7 @@ namespace dlib
- returns false if there are no more elements in the container
!*/
virtual unsigned long size (
virtual size_t size (
) const = 0;
/*!
ensures
......
......@@ -54,7 +54,7 @@ namespace dlib
- #at_start() == true
!*/
virtual unsigned long size (
virtual size_t size (
) const = 0;
/*!
ensures
......@@ -152,7 +152,7 @@ namespace dlib
- #at_start() == true
!*/
virtual unsigned long size (
virtual size_t size (
) const = 0;
/*!
ensures
......
......@@ -63,7 +63,7 @@ namespace dlib
unsigned long& index
);
inline unsigned long size (
inline size_t size (
) const;
inline unsigned char operator[] (
......@@ -208,7 +208,7 @@ namespace dlib
template <
typename sbuf
>
unsigned long lzp_buffer_kernel_1<sbuf>::
size_t lzp_buffer_kernel_1<sbuf>::
size (
) const
{
......
......@@ -63,7 +63,7 @@ namespace dlib
unsigned long& index
);
inline unsigned long size (
inline size_t size (
) const;
inline unsigned char operator[] (
......@@ -291,7 +291,7 @@ namespace dlib
template <
typename sbuf
>
unsigned long lzp_buffer_kernel_2<sbuf>::
size_t lzp_buffer_kernel_2<sbuf>::
size (
) const
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment