[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] tools/golang: When returning pointers, actually allocate structrues



commit 27c176d298cd5866d0ea2cfa5f9068730e57dd37
Author:     George Dunlap <george.dunlap@xxxxxxxxx>
AuthorDate: Fri Apr 19 10:57:04 2024 +0100
Commit:     George Dunlap <george.dunlap@xxxxxxxxx>
CommitDate: Wed Apr 24 16:42:16 2024 +0100

    tools/golang: When returning pointers, actually allocate structrues
    
    In a handful of cases, it was decided to return a pointer to a
    structure rather than the plain structure itself, due to the size.
    However, in these cases the structure was never allocated, leading to
    a nil pointer exception when calling the relevant `fromC` method.
    
    Allocate structures before attempting to fill them in.
    
    Fixes: 453713b1750 ("golang/xenlight: Add host-related functionality")
    Reported-by: Tobias Fitschen <tobias.fitschen@xxxxxxxxx>
    Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxx>
    Tested-by: Tobias Fitschen <tobias.fitschen@xxxxxxxxx>
    Acked-by: Nick Rosbrook <rosbrookn@xxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index a45c636952..d793f172e5 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -999,6 +999,7 @@ func (ctx *Context) GetPhysinfo() (physinfo *Physinfo, err 
error) {
                err = Error(ret)
                return
        }
+       physinfo = &Physinfo{}
        err = physinfo.fromC(&cphys)
 
        return
@@ -1010,6 +1011,7 @@ func (ctx *Context) GetVersionInfo() (info *VersionInfo, 
err error) {
 
        cinfo = C.libxl_get_version_info(ctx.ctx)
 
+       info = &VersionInfo{}
        err = info.fromC(cinfo)
 
        return
@@ -1027,6 +1029,7 @@ func (ctx *Context) DomainInfo(Id Domid) (di *Dominfo, 
err error) {
                return
        }
 
+       di = &Dominfo{}
        err = di.fromC(&cdi)
 
        return
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.