Apple Clang complains about sprintf. Use snprintf instead. (#2862)

Co-authored-by: Your Name <you@example.com>
pull/2866/head
pfeatherstone 1 year ago committed by GitHub
parent c53ff25952
commit dad29bfae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1614,9 +1614,9 @@ namespace dlib
char **mlist;
int mcount;
char *def_str;
char fontset[256];
char fontset[256] = {0};
const long native_font_height = 12;
sprintf(fontset, "-*-*-medium-r-normal--%lu-*-*-*-", native_font_height);
snprintf(fontset, sizeof(fontset), "-*-*-medium-r-normal--%lu-*-*-*-", native_font_height);
x11_stuff.fs = XCreateFontSet(x11_stuff.globals->disp, fontset, &mlist, &mcount, &def_str);
xpoint.x = 0;
xpoint.y = 0;

@ -345,14 +345,13 @@ namespace nativefont
cmap = DefaultColormap(d, DefaultScreen(d));
}
char fontset[256];
char fontset[256] = {0};
{
char *p = fontset;
p += sprintf(fontset, "-*-*-%s-%c-normal--%d-*-*-*-%c",
bold ? "bold" : "medium", italic ? 'i' : 'r', height_want, fixed ? 'c' : 'p');
int offset = snprintf(fontset, sizeof(fontset), "-*-*-%s-%c-normal--%d-*-*-*-%c",
bold ? "bold" : "medium", italic ? 'i' : 'r', height_want, fixed ? 'c' : 'p');
if (fixed){
sprintf(p, ",-*-*-%s-%c-normal--%d-*-*-*-m",
bold ? "bold" : "medium", italic ? 'i' : 'r', height_want);
snprintf(&fontset[offset], sizeof(fontset) - offset, ",-*-*-%s-%c-normal--%d-*-*-*-m",
bold ? "bold" : "medium", italic ? 'i' : 'r', height_want);
}
}
bool equal_font;

@ -119,7 +119,7 @@ namespace dlib
#ifdef __WXMSW__
::ltoa(header_value, buf, 10);
#else
sprintf(buf, "%ld", header_value);
snprintf(buf, sizeof(buf), "%ld", header_value);
#endif
set_header(header_name, buf);
}
@ -154,7 +154,7 @@ namespace dlib
#ifdef __WXMSW__
::ltoa(cookie_value, buf, 10);
#else
sprintf(buf, "%ld", cookie_value);
snprintf(buf, sizeof(buf), "%ld", cookie_value);
#endif
set_cookie(cookie_name, buf);
}

Loading…
Cancel
Save