From ddce3c7b8adf084ca59e2c079b23ea6f9f56b992 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 4 Apr 2021 03:31:17 +0200 Subject: Fix birthday support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcontacts_birthday_destroy.c | 2 +- libcontacts_parse_contact.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libcontacts_birthday_destroy.c b/libcontacts_birthday_destroy.c index c2c1f95..8935b76 100644 --- a/libcontacts_birthday_destroy.c +++ b/libcontacts_birthday_destroy.c @@ -5,5 +5,5 @@ void libcontacts_birthday_destroy(struct libcontacts_birthday *this) { - (void) this; + DESTROY_ALL_STRINGS(this->unrecognised_data); } diff --git a/libcontacts_parse_contact.c b/libcontacts_parse_contact.c index 79dc579..1c2b336 100644 --- a/libcontacts_parse_contact.c +++ b/libcontacts_parse_contact.c @@ -7,6 +7,8 @@ static time_t gettime(const char *data) { time_t ret = 0; + while (*data == ' ' || *data == '\t') data++; + data = &strchr(data, ' ')[1]; if ('1' > *data || *data > '9') return 0; for (; isdigit(*data); data++) { @@ -24,6 +26,8 @@ static unsigned int getposuint(const char *data) { unsigned int ret = 0; + while (*data == ' ' || *data == '\t') data++; + data = &strchr(data, ' ')[1]; if ('1' > *data || *data > '9') return 0; for (; isdigit(*data); data++) { @@ -41,6 +45,8 @@ static unsigned char getposuchar(const char *data) { unsigned char ret = 0; + while (*data == ' ' || *data == '\t') data++; + data = &strchr(data, ' ')[1]; if ('1' > *data || *data > '9') return 0; for (; isdigit(*data); data++) { @@ -419,7 +425,7 @@ libcontacts_parse_contact(char *data, struct libcontacts_contact *contact) break; } else if (!strcmp(p, "BIRTH:") && !contact->birthday) { - contact->birthday = malloc(sizeof(*contact->birthday)); + contact->birthday = calloc(1, sizeof(*contact->birthday)); if (!contact->birthday) goto fail; state = 9; -- cgit v1.2.3-70-g09d2