Skip to content

Commit

Permalink
Replace variable-length char array with std::string
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Rift <[email protected]>
  • Loading branch information
riftEmber committed Jan 8, 2025
1 parent c9a0a1a commit 02f7ea2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/util/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,8 @@ const char* getDirectory(const char* filename) {
if (filenamebase == NULL) {
return astr(".");
} else {
const int len = filenamebase - filename;
char dir[len + 1];
strncpy(dir, filename, len);
dir[len] = '\0';
const int pos = filenamebase - filename;
std::string dir(filename, pos);
return astr(dir);
}
}
Expand Down

0 comments on commit 02f7ea2

Please sign in to comment.