[Liblas-commits] libpc: fix bad cast (#213 from liblas)
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Feb 17 13:23:45 EST 2011
details: http://hg.liblas.orglibpc/rev/b899ec533e10
changeset: 67:b899ec533e10
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Feb 17 10:23:40 2011 -0800
description:
fix bad cast (#213 from liblas)
diffstat:
src/Utils.cpp | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diffs (33 lines):
diff -r ce87b62c31a1 -r b899ec533e10 src/Utils.cpp
--- a/src/Utils.cpp Thu Feb 17 09:22:01 2011 -0800
+++ b/src/Utils.cpp Thu Feb 17 10:23:40 2011 -0800
@@ -85,10 +85,11 @@
// An ofstream is closeable and deletable, but
// an ostream like &std::cout isn't.
if (!ofs) return;
- if (static_cast<io::stream<io::file_sink>&>(*ofs))
+ io::stream<io::file_sink>* sink = dynamic_cast<io::stream<io::file_sink>*>(ofs);
+ if (sink)
{
- static_cast<io::stream<io::file_sink>&>(*ofs).close();
- delete ofs;
+ sink->close();
+ delete sink;
}
}
@@ -100,10 +101,11 @@
// An ifstream is closeable and deletable, but
// an istream like &std::cin isn't.
if (!ifs) return;
- if (static_cast<io::stream<io::file_source>&>(*ifs))
+ io::stream<io::file_source>* source = dynamic_cast<io::stream<io::file_source>*>(ifs);
+ if (source)
{
- static_cast<io::stream<io::file_source>&>(*ifs).close();
- delete ifs;
+ source->close();
+ delete source;
}
}
More information about the Liblas-commits
mailing list