From 50504ab73e396f28f7a370c80c67fe53bb2b35c9 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 10 Feb 2012 14:00:07 +0000 Subject: [PATCH] Do not crash for NULL sort_key Guard against NULL pointer for sort_key and let it behave like an empty string would have been passed in (i.e. no key). --- WHATS_NEW_DM | 1 + libdm/libdm-report.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 2c4a70ffa..44a656c3d 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.70 - =================================== + Do not crash for dm_report_init() sort_key == NULL and behave like "". Return error for failing allocation in dm_asprintf(). Add missing test for failing allocation in dm_realloc() code. Add test for memory allocation failures in regex matcher code. diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index 3d34b7e3a..3f867674a 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -541,6 +541,9 @@ static int _parse_keys(struct dm_report *rh, const char *keys, const char *ws; /* Word start */ const char *we = keys; /* Word end */ + if (!keys) + return 1; + while (*we) { /* Allow consecutive commas */ while (*we && *we == ',')