Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
70aa7bfa
Commit
70aa7bfa
authored
Oct 13, 2012
by
Michal 'vorner' Vaner
Browse files
[2207] Check the load action returns something
NULL makes no sense, so throw in that case.
parent
419020c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/memory/zone_reloader.cc
View file @
70aa7bfa
...
...
@@ -52,6 +52,11 @@ ZoneReloaderLocal::load() {
zone_data_
=
load_action_
(
segment_
->
getMemorySegment
());
if
(
zone_data_
==
NULL
)
{
// Bug inside load_action_.
isc_throw
(
isc
::
Unexpected
,
"No data returned from load action"
);
}
data_ready_
=
true
;
}
...
...
src/lib/datasrc/memory/zone_reloader.h
View file @
70aa7bfa
...
...
@@ -108,6 +108,8 @@ class ZoneSegmentID {};
/// This callback should create new ZoneData (allocated from the passed
/// memory segment) and fill it with relevant loaded data. The caller
/// of the callback takes ownership of the ZoneData.
///
/// It must not return NULL.
typedef
boost
::
function
<
ZoneData
*
(
util
::
MemorySegment
&
)
>
LoadAction
;
/// \brief Install the zone somewhere.
///
...
...
src/lib/datasrc/tests/memory/zone_reloader_unittest.cc
View file @
70aa7bfa
...
...
@@ -52,7 +52,8 @@ public:
load_called_
(
false
),
install_called_
(
false
),
load_throw_
(
false
),
install_throw_
(
false
)
install_throw_
(
false
),
load_null_
(
false
)
{}
void
TearDown
()
{
// Release the reloader
...
...
@@ -67,6 +68,7 @@ protected:
bool
install_called_
;
bool
load_throw_
;
bool
install_throw_
;
bool
load_null_
;
private:
ZoneData
*
loadAction
(
isc
::
util
::
MemorySegment
&
segment
)
{
// Make sure it is the correct segment passed. We know the
...
...
@@ -78,6 +80,10 @@ private:
throw
TestException
();
}
if
(
load_null_
)
{
// Be nasty to the caller and return NULL, which is forbidden
return
(
NULL
);
}
// Create a new zone data. It may be empty for our tests, nothing
// goes inside.
return
(
ZoneData
::
create
(
segment
,
Name
(
"example.org"
)));
...
...
@@ -239,4 +245,16 @@ TEST_F(ZoneReloaderLocalTest, installThrows) {
EXPECT_NO_THROW
(
reloader_
->
cleanup
());
}
// Check the reloader defends itsefl when load action returns NULL
TEST_F
(
ZoneReloaderLocalTest
,
loadNull
)
{
load_null_
=
true
;
EXPECT_THROW
(
reloader_
->
load
(),
isc
::
Unexpected
);
// We can't install that
EXPECT_THROW
(
reloader_
->
install
(),
isc
::
Unexpected
);
// It should be possible to clean up safely
EXPECT_NO_THROW
(
reloader_
->
cleanup
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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