added asserts to prevent segfaults from dereferencing null pointers
This commit is contained in:
parent
78a07b128f
commit
bf6d09e99a
@ -3,6 +3,7 @@
|
||||
#include "string_handling.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
void parse_event(char event_string[], struct event **head) {
|
||||
char *start_date = strstr(event_string, "\r\nDTSTART;");
|
||||
@ -20,6 +21,13 @@ void parse_event(char event_string[], struct event **head) {
|
||||
memset(end_date_str, '\0', 256);
|
||||
memset(summary_str, '\0', 512);
|
||||
|
||||
assert(start_date != NULL);
|
||||
assert(end_date != NULL);
|
||||
assert(sequence != NULL);
|
||||
assert(summary != NULL);
|
||||
assert(location != NULL);
|
||||
assert(transp != NULL);
|
||||
|
||||
strncpy(start_date_str, start_date, end_date - start_date);
|
||||
|
||||
strncpy(end_date_str, end_date, sequence - end_date);
|
||||
|
Loading…
Reference in New Issue
Block a user