From 289cd1f3d499f3f587bed2954dc5d878f75e0c68 Mon Sep 17 00:00:00 2001 From: Felipe Magno de Almeida Date: Thu, 15 Aug 2019 20:47:23 +0000 Subject: [PATCH] eolian-cxx: Fix use after free for base variable T8137 Differential Revision: https://phab.enlightenment.org/D9575 --- src/bin/eolian_cxx/eolian_cxx.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc index 1e0842873d..6f719f178f 100644 --- a/src/bin/eolian_cxx/eolian_cxx.cc +++ b/src/bin/eolian_cxx/eolian_cxx.cc @@ -287,10 +287,10 @@ run(options_type const& opts) { const Eolian_Class *klass = nullptr; char* dup = strdup(opts.in_files[0].c_str()); - char* base = basename(dup); + std::string base (basename(dup)); std::string cpp_types_header; opts.unit = (Eolian_Unit*)opts.state; - klass = ::eolian_state_class_by_file_get(opts.state, base); + klass = ::eolian_state_class_by_file_get(opts.state, base.c_str()); free(dup); if (klass) { @@ -346,8 +346,8 @@ run(options_type const& opts) opts.unit = unit; } char* dup = strdup(name.c_str()); - char* base = basename(dup); - Eolian_Class const* klass = ::eolian_state_class_by_file_get(opts.state, base); + std::string base(basename(dup)); + Eolian_Class const* klass = ::eolian_state_class_by_file_get(opts.state, base.c_str()); free(dup); if (klass) {