diff options
author | Rikard Falkeborn <rikard.falkeborn@gmail.com> | 2015-10-25 12:39:27 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-10-27 14:22:30 +1000 |
commit | 0c5dbdbfeca8a26d015230a8edd6d7c4c91d386a (patch) | |
tree | 6d4721bd0446586a6e8d7528edb3709ba8f2a054 /lib/libalpm | |
parent | 4c5bf09eec4835f8dfd300215f16289d106266d5 (diff) |
Alpm, check for NULL in free-functions
Also, use FREE() instead of free() in _alpm_backup_free()
to set the pointers to NULL.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/backup.c | 7 | ||||
-rw-r--r-- | lib/libalpm/conflict.c | 2 | ||||
-rw-r--r-- | lib/libalpm/db.c | 1 | ||||
-rw-r--r-- | lib/libalpm/delta.c | 1 | ||||
-rw-r--r-- | lib/libalpm/deps.c | 2 | ||||
-rw-r--r-- | lib/libalpm/graph.c | 1 |
6 files changed, 11 insertions, 3 deletions
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index 5ccec036..3d1d6de7 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -76,9 +76,10 @@ alpm_backup_t *_alpm_needbackup(const char *file, alpm_pkg_t *pkg) void _alpm_backup_free(alpm_backup_t *backup) { - free(backup->name); - free(backup->hash); - free(backup); + ASSERT(backup != NULL, return); + FREE(backup->name); + FREE(backup->hash); + FREE(backup); } alpm_backup_t *_alpm_backup_dup(const alpm_backup_t *backup) diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 0af3e3a8..41b8393c 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -68,6 +68,7 @@ error: */ void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict) { + ASSERT(conflict != NULL, return); FREE(conflict->package2); FREE(conflict->package1); FREE(conflict); @@ -301,6 +302,7 @@ error: */ void SYMEXPORT alpm_fileconflict_free(alpm_fileconflict_t *conflict) { + ASSERT(conflict != NULL, return); FREE(conflict->ctarget); FREE(conflict->file); FREE(conflict->target); diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index b94d3342..bb4c4bd9 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -344,6 +344,7 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local) void _alpm_db_free(alpm_db_t *db) { + ASSERT(db != NULL, return); /* cleanup pkgcache */ _alpm_db_free_pkgcache(db); /* cleanup server list */ diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index a43269d0..5ea20692 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -335,6 +335,7 @@ error: void _alpm_delta_free(alpm_delta_t *delta) { + ASSERT(delta != NULL, return); FREE(delta->delta); FREE(delta->delta_md5); FREE(delta->from); diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 34ac8d39..f846b1ce 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -37,6 +37,7 @@ void SYMEXPORT alpm_dep_free(alpm_depend_t *dep) { + ASSERT(dep != NULL, return); FREE(dep->name); FREE(dep->version); FREE(dep->desc); @@ -63,6 +64,7 @@ error: void SYMEXPORT alpm_depmissing_free(alpm_depmissing_t *miss) { + ASSERT(miss != NULL, return); alpm_dep_free(miss->depend); FREE(miss->target); FREE(miss->causingpkg); diff --git a/lib/libalpm/graph.c b/lib/libalpm/graph.c index 4d58169c..7c3cce14 100644 --- a/lib/libalpm/graph.c +++ b/lib/libalpm/graph.c @@ -31,6 +31,7 @@ alpm_graph_t *_alpm_graph_new(void) void _alpm_graph_free(void *data) { + ASSERT(data != NULL, return); alpm_graph_t *graph = data; alpm_list_free(graph->children); free(graph); |