diff mbox series

[2/6] libtraceevent: Fix tep_kbuffer() to have kbuf assign long_size

Message ID 20231224191813.1076074-3-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 014ca2413d0d3a1d6454218c5a17374b335ffb1b
Headers show
Series libtraceevent/kbuffer: Add more kbuffer APIs | expand

Commit Message

Steven Rostedt Dec. 24, 2023, 7:15 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

If the tep handle that returns the kbuf from tep_kbuffer() did not have its
long_size initialized, neither will the kbuffer it returns. This can cause
inconsistent results. Default the long_size to the "commit" size of the header
page as that should also be the size of long.

Fixes: 21ba6336 ("libtraceevent: Add kbuffer_create()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/parse-utils.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/src/parse-utils.c b/src/parse-utils.c
index 9c38e1e644d7..b434e24e44df 100644
--- a/src/parse-utils.c
+++ b/src/parse-utils.c
@@ -137,6 +137,11 @@  struct kbuffer *tep_kbuffer(struct tep_handle *tep)
 	int long_size;
 
 	long_size = tep_get_long_size(tep);
+
+	/* If the long_size is not set, then use the commit size */
+	if (!long_size)
+		long_size = tep_get_header_page_size(tep);
+
 	if (long_size == 8)
 		long_size = KBUFFER_LSIZE_8;
 	else