Compare commits
5 Commits
d973dc1eea
...
1151c6ac0f
Author | SHA1 | Date |
---|---|---|
Alexander Couzens | 1151c6ac0f | |
Alexander Couzens | 8960372ed3 | |
Alexander Couzens | 1a6ceca4b5 | |
Alexander Couzens | 9d7737c4b7 | |
Alexander Couzens | 0d6ef1e8ac |
|
@ -230,7 +230,7 @@ int ogs_dbi_json_init(const char *filepath, const char *apn)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
buf = malloc(filesize);
|
||||
buf = ogs_malloc(filesize);
|
||||
if (!buf) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
|
@ -265,7 +265,6 @@ int ogs_dbi_json_init(const char *filepath, const char *apn)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
/* TODO: replace free with alloc */
|
||||
db_apn = ogs_dbi_static_alloc_apn();
|
||||
if (!db_apn) {
|
||||
ogs_error("Too many APNs\n");
|
||||
|
@ -287,7 +286,6 @@ int ogs_dbi_json_init(const char *filepath, const char *apn)
|
|||
|
||||
entry = ogs_dbi_static_get_apn_profile(db_apn, profile_id);
|
||||
if (entry) {
|
||||
/* TODO: improve error handling!*/
|
||||
ogs_error("Doublicated profile with id %d\n", profile_id);
|
||||
ret = -1;
|
||||
goto fail;
|
||||
|
@ -340,11 +338,23 @@ int ogs_dbi_json_init(const char *filepath, const char *apn)
|
|||
entry->valid = true;
|
||||
}
|
||||
|
||||
if (profiles)
|
||||
cJSON_Delete(profiles);
|
||||
|
||||
if (buf)
|
||||
ogs_free(buf);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (db_apn->apn)
|
||||
ogs_free(db_apn->apn);
|
||||
|
||||
if (profiles)
|
||||
cJSON_Delete(profiles);
|
||||
|
||||
if (buf)
|
||||
free(buf);
|
||||
ogs_free(buf);
|
||||
|
||||
fclose(filefp);
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue