size_t size, n;
fp = fopen(filename, "ro");
+ if (!fp)
+ return NULL;
+
fseek(fp, 0L, SEEK_END);
size = ftell(fp);
vcard_data = calloc(1, size);
static json_object *get_vcards(int max_entries)
{
- json_object *vcards;
+ json_object *vcards = NULL;
gchar *tpath, *filename, *vcards_str = NULL;
tpath = pull_vcards(max_entries);
g_hash_table_remove(xfer_complete, tpath);
g_mutex_unlock(&xfer_complete_mutex);
- vcards = json_object_new_object();
- json_object_object_add(vcards, "vcards", parse_vcards(vcards_str));
- g_free(vcards_str);
-
+ if (vcards_str) {
+ vcards = json_object_new_object();
+ json_object_object_add(vcards, "vcards", parse_vcards(vcards_str));
+ g_free(vcards_str);
+ }
return vcards;
}