Skip to content

Commit 4393fa1

Browse files
ffStrbufLastIndexC: account for empty strings
#285
1 parent 5ae2031 commit 4393fa1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/detection/terminalShell.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ static void getShellVersionZsh(FFstrbuf* exe, FFstrbuf* version)
210210
"--version",
211211
NULL
212212
});
213-
ffStrbufTrimRight(version, '\n');
214213
ffStrbufSubstrBeforeLastC(version, ' ');
215214
ffStrbufSubstrAfterFirstC(version, ' ');
216215
}

src/util/FFstrbuf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf
184184

185185
static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c)
186186
{
187+
if(strbuf->length == 0)
188+
return strbuf->length;
189+
187190
return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c);
188191
}
189192

0 commit comments

Comments
 (0)