exclude: avoid undefined behavior in Exclude::Range
refs #4190
Change-Id: Ib5b6a1cf8bb8d792c805fc42a1e14ef41c9680c1
diff --git a/src/exclude.cpp b/src/exclude.cpp
index 0f339e0..88e51db 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -54,6 +54,20 @@
(a.isNegInf == b.isNegInf && a.component > b.component);
}
+Exclude::Range::Range()
+ : fromInfinity(false)
+ , toInfinity(false)
+{
+}
+
+Exclude::Range::Range(bool fromInfinity, const name::Component& from, bool toInfinity, const name::Component& to)
+ : fromInfinity(fromInfinity)
+ , from(from)
+ , toInfinity(toInfinity)
+ , to(to)
+{
+}
+
bool
Exclude::Range::operator==(const Exclude::Range& other) const
{
diff --git a/src/exclude.hpp b/src/exclude.hpp
index 595f143..23dac46 100644
--- a/src/exclude.hpp
+++ b/src/exclude.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -21,8 +21,8 @@
* @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
*/
-#ifndef NDN_EXCLUDE_H
-#define NDN_EXCLUDE_H
+#ifndef NDN_EXCLUDE_HPP
+#define NDN_EXCLUDE_HPP
#include "name-component.hpp"
#include "encoding/encoding-buffer.hpp"
@@ -177,6 +177,10 @@
class Range
{
public:
+ Range();
+
+ Range(bool fromInfinity, const name::Component& from, bool toInfinity, const name::Component& to);
+
/**
* @retval true A single component is excluded
* @retval false A range of more than one components are excluded
@@ -365,4 +369,4 @@
} // namespace ndn
-#endif // NDN_EXCLUDE_H
+#endif // NDN_EXCLUDE_HPP