Skip to content

Commit fc77108

Browse files
authored
Common: fixes segmentation fault triggered by dereferencing value at negative index (#2198)
1 parent e22a999 commit fc77108

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/common/impl/format.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
204204
uint32_t index = getArgumentIndex(placeholderValue.chars, numArgs, arguments);
205205

206206
// testing for an invalid index
207-
if (index > numArgs)
207+
if (index > numArgs || index < 1)
208208
{
209209
appendInvalidPlaceholder(buffer, "{?", &placeholderValue, i, formatstr->length);
210210
continue;
@@ -230,7 +230,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
230230
uint32_t index = getArgumentIndex(placeholderValue.chars, numArgs, arguments);
231231

232232
// testing for an invalid index
233-
if (index > numArgs)
233+
if (index > numArgs || index < 1)
234234
{
235235
appendInvalidPlaceholder(buffer, "{/", &placeholderValue, i, formatstr->length);
236236
continue;

0 commit comments

Comments
 (0)