File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,7 +237,10 @@ drain:
237237
238238 // free(NULL) is safe
239239 C .free (unsafe .Pointer (oldCursor ))
240- C .sd_journal_get_cursor (j , & cursor )
240+ if C .sd_journal_get_cursor (j , & cursor ) != 0 {
241+ // ensure that we won't be freeing an address that's invalid
242+ cursor = nil
243+ }
241244 return cursor
242245}
243246
@@ -271,7 +274,6 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
271274 s .readers .mu .Lock ()
272275 delete (s .readers .readers , logWatcher )
273276 s .readers .mu .Unlock ()
274- C .sd_journal_close (j )
275277 close (logWatcher .Msg )
276278 }()
277279 // Wait until we're told to stop.
@@ -305,9 +307,9 @@ func (s *journald) readLogs(logWatcher *logger.LogWatcher, config logger.ReadCon
305307 following := false
306308 defer func (pfollowing * bool ) {
307309 if ! * pfollowing {
308- C .sd_journal_close (j )
309310 close (logWatcher .Msg )
310311 }
312+ C .sd_journal_close (j )
311313 }(& following )
312314 // Remove limits on the size of data items that we'll retrieve.
313315 rc = C .sd_journal_set_data_threshold (j , C .size_t (0 ))
You can’t perform that action at this time.
0 commit comments