This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository ego.

View the commit online.

commit 62b0b5bcf0cd40479a02a63b147b2b1b36ccdcd8
Author: [email protected] <[email protected]>
AuthorDate: Thu Mar 26 21:58:03 2026 -0600

    fix(eet): address code review findings for safety and correctness
    
    - marshal.go: Fix uintptr store in marshalScalarElem to use unsafe.Pointer
      for type-safe pointer operations on string elements in scalar arrays.
    
    - unmarshal.go: Replace direct node.next field access with C wrapper
      _ego_eet_list_next_node, since eina_list_next is an inline function
      not directly callable from cgo.
    
    - codec.go: Guard Decode against nil/empty input by checking len(data)==0
      before attempting to decode, preventing panic on invalid input.
    
    - descriptor.go: Reject zero-size nested structs that have no serialisable
      fields, preventing EET descriptor creation for empty struct types.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 eet/codec.go      | 4 ++++
 eet/descriptor.go | 3 +++
 eet/marshal.go    | 2 +-
 eet/unmarshal.go  | 6 +++++-
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/eet/codec.go b/eet/codec.go
index 961ed02..83d9639 100644
--- a/eet/codec.go
+++ b/eet/codec.go
@@ -109,6 +109,10 @@ func Decode[T any](data []byte) (*T, error) {
 		return nil, err
 	}
 
+	if len(data) == 0 {
+		return nil, ErrDecode
+	}
+
 	buf := C._ego_eet_data_descriptor_decode(ti.desc, unsafe.Pointer(&data[0]), C.int(len(data)))
 	if buf == nil {
 		return nil, ErrDecode
diff --git a/eet/descriptor.go b/eet/descriptor.go
index 0cb4fda..951fa5e 100644
--- a/eet/descriptor.go
+++ b/eet/descriptor.go
@@ -321,6 +321,9 @@ func resolveEETType(t reflect.Type, tag FieldTag) (eetType, groupType C.int, sub
 		if serr != nil {
 			return 0, 0, nil, serr
 		}
+		if sub.shadowSize == 0 {
+			return 0, 0, nil, fmt.Errorf("%w: struct %s has no serialisable fields", ErrUnsupported, t.Name())
+		}
 		return C.EET_T_UNKNOW, C.EET_G_UNKNOWN_NESTED, sub, nil
 
 	case reflect.Pointer:
diff --git a/eet/marshal.go b/eet/marshal.go
index ef632eb..d46a07c 100644
--- a/eet/marshal.go
+++ b/eet/marshal.go
@@ -279,7 +279,7 @@ func marshalScalarElem(ev reflect.Value, dst unsafe.Pointer, sub *typeInfo, addE
 	case reflect.String:
 		cs := C.CString(ev.String())
 		addExtra(unsafe.Pointer(cs))
-		*(*uintptr)(dst) = uintptr(unsafe.Pointer(cs))
+		*(*unsafe.Pointer)(dst) = unsafe.Pointer(cs)
 	case reflect.Struct:
 		if sub == nil {
 			return fmt.Errorf("%w: no subInfo for struct elem", ErrUnsupported)
diff --git a/eet/unmarshal.go b/eet/unmarshal.go
index 3a0c048..939b3bd 100644
--- a/eet/unmarshal.go
+++ b/eet/unmarshal.go
@@ -4,6 +4,10 @@ package eet
 #include <Eet.h>
 #include <Eina.h>
 #include <stdlib.h>
+
+static Eina_List *_ego_eet_list_next_node(Eina_List *l) {
+    return eina_list_next(l);
+}
 */
 import "C"
 import (
@@ -126,7 +130,7 @@ func unmarshalSlice(ptr unsafe.Pointer, fv reflect.Value, fd fieldDescriptor) er
 				return err
 			}
 			elems = append(elems, ev)
-			node = (*C.Eina_List)(unsafe.Pointer(node.next))
+			node = C._ego_eet_list_next_node(node)
 		}
 		sl := reflect.MakeSlice(fv.Type(), len(elems), len(elems))
 		for i, ev := range elems {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to