@@ -165,51 +165,38 @@ lockdownd_error_t lockdown_check_result(plist_t dict, const char *query_match)
165
165
return ret ;
166
166
}
167
167
168
- char * query_value = NULL ;
169
-
170
- plist_get_string_val (query_node , & query_value );
168
+ const char * query_value = plist_get_string_ptr (query_node , NULL );
171
169
if (!query_value ) {
172
170
return ret ;
173
171
}
174
172
175
173
if (query_match && (strcmp (query_value , query_match ) != 0 )) {
176
- free (query_value );
177
174
return ret ;
178
175
}
179
176
180
- free (query_value );
181
-
182
- plist_t result_node = plist_dict_get_item (dict , "Result" );
183
- if (!result_node ) {
184
- /* iOS 5: the 'Result' key is not present anymore.
185
- But we need to check for the 'Error' key. */
186
- plist_t err_node = plist_dict_get_item (dict , "Error" );
187
- if (err_node ) {
188
- if (plist_get_node_type (err_node ) == PLIST_STRING ) {
189
- char * err_value = NULL ;
190
-
191
- plist_get_string_val (err_node , & err_value );
192
- if (err_value ) {
193
- debug_info ("ERROR: %s" , err_value );
194
- ret = lockdownd_strtoerr (err_value );
195
- free (err_value );
196
- } else {
197
- debug_info ("ERROR: unknown error occurred" );
198
- }
177
+ /* Check for 'Error' in reply */
178
+ plist_t err_node = plist_dict_get_item (dict , "Error" );
179
+ if (err_node ) {
180
+ if (plist_get_node_type (err_node ) == PLIST_STRING ) {
181
+ const char * err_value = plist_get_string_ptr (err_node , NULL );
182
+ if (err_value ) {
183
+ debug_info ("ERROR: %s" , err_value );
184
+ ret = lockdownd_strtoerr (err_value );
185
+ } else {
186
+ debug_info ("ERROR: unknown error occurred" );
199
187
}
200
- return ret ;
201
188
}
202
-
203
- ret = LOCKDOWN_E_SUCCESS ;
204
-
205
189
return ret ;
206
190
}
207
191
208
- plist_type result_type = plist_get_node_type (result_node );
209
- if (result_type == PLIST_STRING ) {
210
- char * result_value = NULL ;
211
-
212
- plist_get_string_val (result_node , & result_value );
192
+ plist_t result_node = plist_dict_get_item (dict , "Result" );
193
+ if (!result_node ) {
194
+ /* With iOS 5+ 'Result' is not present anymore.
195
+ If there is no 'Error', we can just assume success. */
196
+ return LOCKDOWN_E_SUCCESS ;
197
+ }
198
+ if (plist_get_node_type (result_node ) == PLIST_STRING ) {
199
+ const char * result_value = plist_get_string_ptr (result_node , NULL );
213
200
if (result_value ) {
214
201
if (!strcmp (result_value , "Success" )) {
215
202
ret = LOCKDOWN_E_SUCCESS ;
@@ -219,9 +206,6 @@ lockdownd_error_t lockdown_check_result(plist_t dict, const char *query_match)
219
206
debug_info ("ERROR: unknown result value '%s'" , result_value );
220
207
}
221
208
}
222
-
223
- if (result_value )
224
- free (result_value );
225
209
}
226
210
227
211
return ret ;
0 commit comments