summaryrefslogtreecommitdiff
path: root/src/journal/journal-file.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-08 23:54:21 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-08 23:54:21 +0200
commit64825d3c589cd8742887f30acde8c57eceac2001 (patch)
tree880c0f250aff9efb4aa2c2a892ad29479a987462 /src/journal/journal-file.c
parentc269cec334f940d82146f70d69125b1caef08baa (diff)
fix a couple of issues found with llvm-analyze
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r--src/journal/journal-file.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index b840124c9f..718dc5d6ea 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -788,7 +788,7 @@ static int journal_file_append_data(
}
#endif
- if (!compressed)
+ if (!compressed && size > 0)
memcpy(o->data.payload, data, size);
r = journal_file_link_data(f, o, p, hash);
@@ -1057,7 +1057,8 @@ int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const st
ts->monotonic < le64toh(f->header->tail_entry_monotonic))
return -EINVAL;
- items = alloca(sizeof(EntryItem) * n_iovec);
+ /* alloca() can't take 0, hence let's allocate at least one */
+ items = alloca(sizeof(EntryItem) * MAX(1, n_iovec));
for (i = 0; i < n_iovec; i++) {
uint64_t p;
@@ -2336,7 +2337,8 @@ int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t m
n_list ++;
}
- qsort(list, n_list, sizeof(struct vacuum_info), vacuum_compare);
+ if (n_list > 0)
+ qsort(list, n_list, sizeof(struct vacuum_info), vacuum_compare);
for(i = 0; i < n_list; i++) {
struct statvfs ss;