[LIBREPORT PATCH] cmp_problem_data: use 0 for value if element is missing
Jakub Filak
jfilak at redhat.com
Mon May 20 13:54:50 UTC 2013
NULL element value causes crashes but NULL is used only if element is
missing. Therefore we can make a compromise that NULL means 0.
Related to abrt/abrt#650
Signed-off-by: Jakub Filak <jfilak at redhat.com>
---
src/lib/problem_data.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
index e6b2a20..c3da1e7 100644
--- a/src/lib/problem_data.c
+++ b/src/lib/problem_data.c
@@ -540,11 +540,11 @@ gint cmp_problem_data(gconstpointer a, gconstpointer b, gpointer filename)
{
problem_data_t *a_data = *(problem_data_t **) a;
const char *a_time_str = problem_data_get_content_or_NULL(a_data, filename);
- unsigned long a_time= strtoul(a_time_str, NULL, 10);
+ unsigned long a_time = a_time_str ? strtoul(a_time_str, NULL, 10) : 0;
problem_data_t *b_data = *(problem_data_t **) b;
const char *b_time_str = problem_data_get_content_or_NULL(b_data, filename);
- unsigned long b_time= strtoul(b_time_str, NULL, 10);
+ unsigned long b_time= b_time_str ? strtoul(b_time_str, NULL, 10) : 0;
/* newer first */
if (a_time > b_time)
--
1.8.1.4
More information about the Crash-catcher
mailing list