Skip to content

Commit

Permalink
Use sprintf instead of strcpy
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Dec 20, 2023
1 parent 139d194 commit 4f47fcc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions ros_gz_sim/src/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <gz/msgs/entity_factory.pb.h>
#include <gz/msgs/stringmsg_v.pb.h>

#include <cstring>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -60,7 +59,7 @@ int main(int _argc, char ** _argv)
char ** filtered_argv = new char *[(filtered_argc + 1)];
for (int ii = 0; ii < filtered_argc; ++ii) {
filtered_argv[ii] = new char[filtered_arguments[ii].size() + 1];
std::strcpy(filtered_argv[ii], filtered_arguments[ii].c_str());
snprintf(filtered_argv[ii], filtered_arguments[ii].size() + 1, "%s", filtered_arguments[ii].c_str());
}
filtered_argv[filtered_argc] = nullptr;

Expand Down

0 comments on commit 4f47fcc

Please sign in to comment.