mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 05:08:21 +01:00
pnmdec.c: use snprintf instead of sprintf
this is consistent with the rest of the example code Change-Id: Id4c02e16be84fbe21ddc74c9049d8cbda2d875a8
This commit is contained in:
parent
3f73e8f7ac
commit
fad0ece7ed
@ -20,6 +20,10 @@
|
||||
#include "webp/encode.h"
|
||||
#include "./imageio_util.h"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
WIDTH_FLAG = 1 << 0,
|
||||
HEIGHT_FLAG = 1 << 1,
|
||||
@ -111,8 +115,9 @@ static size_t ReadPAMFields(PNMInfo* const info, size_t off) {
|
||||
break;
|
||||
} else {
|
||||
static const char kEllipsis[] = " ...";
|
||||
const size_t kLen = strlen(kEllipsis) + 1; // +1 = trailing \0
|
||||
int i;
|
||||
if (out_size > 20) sprintf(out + 20 - strlen(kEllipsis), kEllipsis);
|
||||
if (out_size > 20) snprintf(out + 20 - kLen, kLen, kEllipsis);
|
||||
for (i = 0; i < (int)strlen(out); ++i) {
|
||||
// isprint() might trigger a "char-subscripts" warning if given a char.
|
||||
if (!isprint((int)out[i])) out[i] = ' ';
|
||||
|
Loading…
Reference in New Issue
Block a user