Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
43f983f3
Commit
43f983f3
authored
Jan 16, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug which could potentially occur when empty std::vector<char>
or std::vector<unsigned char> were serialized.
parent
721d55a6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
serialize.h
dlib/serialize.h
+4
-0
serialize.cpp
dlib/test/serialize.cpp
+8
-0
No files found.
dlib/serialize.h
View file @
43f983f3
...
...
@@ -893,6 +893,7 @@ namespace dlib
{
const
unsigned
long
size
=
static_cast
<
unsigned
long
>
(
item
.
size
());
serialize
(
size
,
out
);
if
(
item
.
size
()
!=
0
)
out
.
write
(
&
item
[
0
],
item
.
size
());
}
catch
(
serialization_error
&
e
)
...
...
@@ -910,6 +911,7 @@ namespace dlib
unsigned
long
size
;
deserialize
(
size
,
in
);
item
.
resize
(
size
);
if
(
item
.
size
()
!=
0
)
in
.
read
(
&
item
[
0
],
item
.
size
());
}
catch
(
serialization_error
&
e
)
...
...
@@ -928,6 +930,7 @@ namespace dlib
{
const
unsigned
long
size
=
static_cast
<
unsigned
long
>
(
item
.
size
());
serialize
(
size
,
out
);
if
(
item
.
size
()
!=
0
)
out
.
write
((
char
*
)
&
item
[
0
],
item
.
size
());
}
catch
(
serialization_error
&
e
)
...
...
@@ -945,6 +948,7 @@ namespace dlib
unsigned
long
size
;
deserialize
(
size
,
in
);
item
.
resize
(
size
);
if
(
item
.
size
()
!=
0
)
in
.
read
((
char
*
)
&
item
[
0
],
item
.
size
());
}
catch
(
serialization_error
&
e
)
...
...
dlib/test/serialize.cpp
View file @
43f983f3
...
...
@@ -528,6 +528,14 @@ namespace
{
DLIB_TEST
(
a
[
i
]
==
b
[
i
]);
}
std
::
vector
<
T
>
c
;
sout
.
str
(
""
);
dlib
::
serialize
(
c
,
sout
);
sin
.
str
(
sout
.
str
());
dlib
::
deserialize
(
a
,
sin
);
DLIB_TEST
(
a
.
size
()
==
0
);
DLIB_TEST
(
c
.
size
()
==
0
);
}
void
test_vector_bool
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment