From 81b06fad98ac4210c5b1d04dddeed628a8e0accb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 29 Jan 2018 08:24:41 +0000 Subject: Using std::string instead of char array for file names (overflow detected by fortify) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3171 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b590989d278e00aec79d6a7bc2b72088b5cb0e57 --- src/Nerve_GIC/include/gudhi/GIC.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/Nerve_GIC/include') diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index 642b88b0..58831bbf 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -376,8 +376,7 @@ class Cover_complex { double d; std::vector zeros(n); for (int i = 0; i < n; i++) distances.push_back(zeros); - std::string distance = point_cloud_name; - distance.append("_dist"); + std::string distance = point_cloud_name + "_dist"; std::ifstream input(distance.c_str(), std::ios::out | std::ios::binary); if (input.good()) { @@ -481,10 +480,8 @@ class Cover_complex { */ void set_function_from_coordinate(int k) { for (int i = 0; i < n; i++) func.emplace(i, point_cloud[i][k]); - char coordinate[100]; - sprintf(coordinate, "coordinate %d", k); functional_cover = true; - cover_name = coordinate; + cover_name = "coordinate " + std::to_string(k); } public: // Set function from vector. @@ -897,9 +894,8 @@ class Cover_complex { * of its 1-skeleton in a .pdf file. */ void plot_DOT() { - char mapp[100]; - sprintf(mapp, "%s_sc.dot", point_cloud_name.c_str()); - std::ofstream graphic(mapp); + std::string mapp = point_cloud_name + "_sc.dot"; + std::ofstream graphic(mapp.c_str()); double maxv = std::numeric_limits::lowest(); double minv = std::numeric_limits::max(); @@ -948,9 +944,8 @@ class Cover_complex { void write_info() { int num_simplices = simplices.size(); int num_edges = 0; - char mapp[100]; - sprintf(mapp, "%s_sc.txt", point_cloud_name.c_str()); - std::ofstream graphic(mapp); + std::string mapp = point_cloud_name + "_sc.dot"; + std::ofstream graphic(mapp.c_str()); for (int i = 0; i < num_simplices; i++) if (simplices[i].size() == 2) @@ -993,9 +988,8 @@ class Cover_complex { std::vector > edges, faces; int numsimplices = simplices.size(); - char gic[100]; - sprintf(gic, "%s_sc.off", point_cloud_name.c_str()); - std::ofstream graphic(gic); + std::string mapp = point_cloud_name + "_sc.dot"; + std::ofstream graphic(mapp.c_str()); graphic << "OFF" << std::endl; for (int i = 0; i < numsimplices; i++) { -- cgit v1.2.3