BUG/MINOR: http/sample: gmtime/localtime can fail

The man said that gmtime() and localtime() can return a NULL value.
This is not tested. It appears that all the values of a 32 bit integer
are valid, but it is better to check the return of these functions.

However, if the integer move from 32 bits to 64 bits, some 64 values
can be unsupported.
diff --git a/src/proto_http.c b/src/proto_http.c
index 0ebc2c4..69ad908 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -12084,6 +12084,8 @@
 		curr_date += args[0].data.sint;
 
 	tm = gmtime(&curr_date);
+	if (!tm)
+		return 0;
 
 	temp = get_trash_chunk();
 	temp->len = snprintf(temp->str, temp->size - temp->len,
diff --git a/src/sample.c b/src/sample.c
index 6088869..0a09012 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -1519,13 +1519,17 @@
 {
 	struct chunk *temp;
 	time_t curr_date = smp->data.uint;
+	struct tm *tm;
 
 	/* add offset */
 	if (args[1].type == ARGT_SINT || args[1].type == ARGT_UINT)
 		curr_date += args[1].data.sint;
 
+	tm = localtime(&curr_date);
+	if (!tm)
+		return 0;
 	temp = get_trash_chunk();
-	temp->len = strftime(temp->str, temp->size, args[0].data.str.str, localtime(&curr_date));
+	temp->len = strftime(temp->str, temp->size, args[0].data.str.str, tm);
 	smp->data.str = *temp;
 	smp->type = SMP_T_STR;
 	return 1;
@@ -1549,13 +1553,17 @@
 {
 	struct chunk *temp;
 	time_t curr_date = smp->data.uint;
+	struct tm *tm;
 
 	/* add offset */
 	if (args[1].type == ARGT_SINT || args[1].type == ARGT_UINT)
 		curr_date += args[1].data.sint;
 
+	tm = gmtime(&curr_date);
+	if (!tm)
+		return 0;
 	temp = get_trash_chunk();
-	temp->len = strftime(temp->str, temp->size, args[0].data.str.str, gmtime(&curr_date));
+	temp->len = strftime(temp->str, temp->size, args[0].data.str.str, tm);
 	smp->data.str = *temp;
 	smp->type = SMP_T_STR;
 	return 1;