Skip to content

Commit e96c6b1

Browse files
code review from coderabbitai
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent a6ac567 commit e96c6b1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/CLR/Helpers/nanoprintf/nanoprintf.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,14 +1256,10 @@ printf_t vsnprintf_(char *buffer, size_t bufsz, char const *format, va_list vlis
12561256
va_copy(vlistCopy, vlist);
12571257

12581258
// Perform the actual formatting operation
1259-
count = doprnt(&buffer, putbuf, bufsz, format, vlistCopy);
1259+
count = doprnt(&buffer, putbuf, bufsz > 0 ? bufsz - 1 : 0, format, vlistCopy);
12601260

12611261
// append null terminator
1262-
if(count < bufsz)
1263-
{
1264-
buffer[count] = '\0';
1265-
}
1266-
else
1262+
if (bufsz > 0)
12671263
{
12681264
buffer[bufsz - 1] = '\0';
12691265
}

0 commit comments

Comments
 (0)