Skip to content

Commit

Permalink
Prefer snprintf to sprintf
Browse files Browse the repository at this point in the history
This also simplifies advancing `ptr`
  • Loading branch information
Rangi42 committed Sep 15, 2024
1 parent 02439b1 commit 9b3d19c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/gfx/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ static std::tuple<DefaultInitVec<size_t>, std::vector<Palette>>
static char buf[sizeof(", $XXXX, $XXXX, $XXXX, $XXXX")];
char *ptr = buf;
for (uint16_t cgbColor : list) {
sprintf(ptr, ", $%04x", cgbColor);
ptr += QUOTEDSTRLEN(", $XXXX");
ptr += snprintf(ptr, sizeof(", $XXXX"), ", $%04x", cgbColor);
}
return &buf[QUOTEDSTRLEN(", ")];
};
Expand Down

0 comments on commit 9b3d19c

Please sign in to comment.