Previously, when integer was larger than the padded width in a integer
specifier, the "end" pointer was evaluated to a value before "buf"
pointer.
Found by UndefinedBehaviorSanitizer.
} while (ui64 != 0);
}
- /* Zero or space padding. */
+ length = (temp + NJS_INT64_T_LEN) - p;
- if (spf->width != 0) {
+ /* Zero or space padding. */
- length = (temp + NJS_INT64_T_LEN) - p;
- end = buf + (spf->width - length);
+ if (length < spf->width) {
+ end = buf + spf->width - length;
end = njs_min(end, spf->end);
while (buf < end) {
/* Number copying. */
- length = (temp + NJS_INT64_T_LEN) - p;
end = buf + length;
end = njs_min(end, spf->end);