aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-12 17:38:21 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-12 17:38:21 +0400
commit6165ab1a40624aff8627b89db4115844d485d3d1 (patch)
tree0dfee5be5a97ccb2e66eadd3db67aae621c80e37
parent45a890e23bdca0d6e50f36bd74c19c5857fa883b (diff)
downloadrspamd-6165ab1a40624aff8627b89db4115844d485d3d1.tar.gz
rspamd-6165ab1a40624aff8627b89db4115844d485d3d1.zip
Do not panic when json buffer is NULL or empty.
-rw-r--r--src/json/load.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/json/load.c b/src/json/load.c
index 0f0968e9e..45ff45d67 100644
--- a/src/json/load.c
+++ b/src/json/load.c
@@ -795,6 +795,11 @@ json_loads (const char *string, json_error_t * error)
.pos = 0
};
+ if (string == NULL || *string == '\0') {
+ error_set (error, NULL, "empty stream");
+ return NULL;
+ }
+
if (lex_init (&lex, string_get, string_eof, (void *)&stream_data))
return NULL;
@@ -892,6 +897,11 @@ json_load_evbuffer (struct evbuffer *evb, json_error_t *error)
lex_t lex;
json_t *result;
+ if (evb == NULL || EVBUFFER_LENGTH (evb) == 0) {
+ error_set (error, NULL, "empty stream");
+ return NULL;
+ }
+
stream_data.data = EVBUFFER_DATA (evb);
stream_data.pos = 0;
stream_data.len = EVBUFFER_LENGTH (evb);