Skip to content
Snippets Groups Projects
Commit 1cbd13e6 authored by Luca Bruno's avatar Luca Bruno Committed by GitHub
Browse files

Merge pull request #194 from amenzhinsky/master

sdjournal: fix memory leak in cursor handling
parents 5c49e485 c064913e
No related branches found
No related tags found
No related merge requests found
......@@ -736,6 +736,8 @@ func (j *Journal) GetEntry() (*JournalEntry, error) {
entry.MonotonicTimestamp = uint64(monotonicUsec)
var c *C.char
defer C.free(unsafe.Pointer(c))
r = C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &c)
if r < 0 {
return nil, fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r))
......@@ -834,13 +836,14 @@ func (j *Journal) GetMonotonicUsec() (uint64, error) {
// GetCursor gets the cursor of the current journal entry.
func (j *Journal) GetCursor() (string, error) {
var d *C.char
sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor")
if err != nil {
return "", err
}
var d *C.char
defer C.free(unsafe.Pointer(d))
j.mu.Lock()
r := C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &d)
j.mu.Unlock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment