mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
examples: replace sprintf() with snprintf()
snprintf() is more preferred to use in preventing buffer overflow.
This commit is contained in:
parent
cc0abf18cb
commit
3ae9e33c65
3 changed files with 3 additions and 3 deletions
|
@ -51,7 +51,7 @@ void tvgDrawCmds(tvg::Canvas* canvas, const char* path, const char* name)
|
|||
auto picture = tvg::Picture::gen();
|
||||
|
||||
char buf[PATH_MAX];
|
||||
sprintf(buf,"%s/%s", path, name);
|
||||
snprintf(buf, sizeof(buf), "%s/%s", path, name);
|
||||
|
||||
if (picture->load(buf) != tvg::Result::Success) return;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void svgDirCallback(const char* name, const char* path, void* data)
|
|||
auto picture = tvg::Picture::gen();
|
||||
|
||||
char buf[PATH_MAX];
|
||||
sprintf(buf, "/%s/%s", path, name);
|
||||
snprintf(buf, sizeof(buf), "/%s/%s", path, name);
|
||||
|
||||
if (picture->load(buf) != tvg::Result::Success) return;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void svgDirCallback(const char* name, const char* path, void* data)
|
|||
auto picture = tvg::Picture::gen();
|
||||
|
||||
char buf[PATH_MAX];
|
||||
sprintf(buf, "/%s/%s", path, name);
|
||||
snprintf(buf, sizeof(buf), "/%s/%s", path, name);
|
||||
|
||||
if (picture->load(buf) != tvg::Result::Success) return;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue