Skip to content

Commit 5c4e670

Browse files
committed
fix: check data nil
Signed-off-by: aimuz <[email protected]>
1 parent ec6347c commit 5c4e670

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

klog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ func (l *loggingT) output(s severity.Severity, logger *logWriter, buf *buffer.Bu
873873
if logger.writeKlogBuffer != nil {
874874
logger.writeKlogBuffer(data)
875875
} else {
876-
if data[len(data)-1] == '\n' {
876+
if len(data) > 0 && data[len(data)-1] == '\n' {
877877
data = data[:len(data)-1]
878878
}
879879
// TODO: set 'severity' and caller information as structured log info

0 commit comments

Comments
 (0)