Skip to content

Commit adea101

Browse files
authored
Merge pull request #47 from dylanhitt/main
fix: handle GError a bit early in some cases
2 parents 6466409 + f8158ba commit adea101

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

frida/device.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ func (d *Device) params(opts options) (map[string]any, error) {
173173

174174
var err *C.GError
175175
ht := C.frida_device_query_system_parameters_sync(d.device, opts.cancellable, &err)
176-
177-
return gHashTableToMap(ht), handleGError(err)
176+
if err != nil {
177+
return nil, handleGError(err)
178+
}
179+
return gHashTableToMap(ht), nil
178180
}
179181

180182
// FrontmostApplication will return the frontmost application or the application in focus

frida/service.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ func (s *Service) Request(req any) (any, error) {
3131

3232
var err *C.GError
3333
resp := C.frida_service_request_sync(s.service, variant, nil, &err)
34-
35-
return gVariantToGo(resp), handleGError(err)
34+
if err != nil {
35+
return nil, handleGError(err)
36+
}
37+
return gVariantToGo(resp), nil
3638
}
3739

3840
func (s *Service) Activate() error {

frida/session.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ func (s *Session) CompileScript(script string, opts *ScriptOptions) ([]byte, err
121121
scriptC,
122122
opts.opts,
123123
nil,
124-
&err)
125-
126-
return getGBytes(bts), handleGError(err)
124+
&err,
125+
)
126+
if err != nil {
127+
return nil, handleGError(err)
128+
}
129+
return getGBytes(bts), nil
127130
}
128131

129132
// SnapshotScript creates snapshot from the script.
@@ -137,9 +140,12 @@ func (s *Session) SnapshotScript(embedScript string, snapshotOpts *SnapshotOptio
137140
embedScriptC,
138141
snapshotOpts.opts,
139142
nil,
140-
&err)
141-
142-
return getGBytes(ret), handleGError(err)
143+
&err,
144+
)
145+
if err != nil {
146+
return nil, handleGError(err)
147+
}
148+
return getGBytes(ret), nil
143149
}
144150

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

0 commit comments

Comments
 (0)