Skip to content

Commit

Permalink
Merge pull request #47 from dylanhitt/main
Browse files Browse the repository at this point in the history
fix: handle GError a bit early in some cases
  • Loading branch information
NSEcho authored Oct 3, 2024
2 parents 6466409 + f8158ba commit adea101
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 4 additions & 2 deletions frida/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ func (d *Device) params(opts options) (map[string]any, error) {

var err *C.GError
ht := C.frida_device_query_system_parameters_sync(d.device, opts.cancellable, &err)

return gHashTableToMap(ht), handleGError(err)
if err != nil {
return nil, handleGError(err)
}
return gHashTableToMap(ht), nil
}

// FrontmostApplication will return the frontmost application or the application in focus
Expand Down
6 changes: 4 additions & 2 deletions frida/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ func (s *Service) Request(req any) (any, error) {

var err *C.GError
resp := C.frida_service_request_sync(s.service, variant, nil, &err)

return gVariantToGo(resp), handleGError(err)
if err != nil {
return nil, handleGError(err)
}
return gVariantToGo(resp), nil
}

func (s *Service) Activate() error {
Expand Down
18 changes: 12 additions & 6 deletions frida/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ func (s *Session) CompileScript(script string, opts *ScriptOptions) ([]byte, err
scriptC,
opts.opts,
nil,
&err)

return getGBytes(bts), handleGError(err)
&err,
)
if err != nil {
return nil, handleGError(err)
}
return getGBytes(bts), nil
}

// SnapshotScript creates snapshot from the script.
Expand All @@ -137,9 +140,12 @@ func (s *Session) SnapshotScript(embedScript string, snapshotOpts *SnapshotOptio
embedScriptC,
snapshotOpts.opts,
nil,
&err)

return getGBytes(ret), handleGError(err)
&err,
)
if err != nil {
return nil, handleGError(err)
}
return getGBytes(ret), nil
}

// SetupPeerConnection sets up peer (p2p) connection with peer options provided.
Expand Down

0 comments on commit adea101

Please sign in to comment.