[PATCH i-g-t v12 03/11] tests/intel/*_intel_bb: handle base64 encode fail

Jeevaka Prabu Badrappan jeevaka.badrappan at intel.com
Mon Jun 2 19:25:07 UTC 2025


g_base64_encode function returns a newly allocated string containing
the Base64 encoded data. Upon failure, null can be returned.

When g_base64_encode function fails, exit the calling function with
error.

Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan at intel.com>
---
 tests/intel/api_intel_bb.c | 3 +++
 tests/intel/xe_intel_bb.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/tests/intel/api_intel_bb.c b/tests/intel/api_intel_bb.c
index 4a1c9be91..13b1091d8 100644
--- a/tests/intel/api_intel_bb.c
+++ b/tests/intel/api_intel_bb.c
@@ -944,6 +944,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
 
 		igt_info("--- %s ---\n", name);
 		pos = str = g_base64_encode(destbuf, outsize);
+		if (str == NULL)
+			return -1;
+
 		outsize = strlen(str);
 		while (pos) {
 			char line[LINELEN + 1];
diff --git a/tests/intel/xe_intel_bb.c b/tests/intel/xe_intel_bb.c
index d8bd7b519..ef95b4a2a 100644
--- a/tests/intel/xe_intel_bb.c
+++ b/tests/intel/xe_intel_bb.c
@@ -595,6 +595,9 @@ static int dump_base64(const char *name, struct intel_buf *buf)
 
 		igt_info("--- %s ---\n", name);
 		pos = str = g_base64_encode(destbuf, outsize);
+		if (str == NULL)
+			return -1;
+
 		outsize = strlen(str);
 		while (pos) {
 			char line[LINELEN + 1];
-- 
2.49.0



More information about the igt-dev mailing list