]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add additional safe guard for nan values
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 25 Jan 2017 13:37:51 +0000 (13:37 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 25 Jan 2017 13:37:51 +0000 (13:37 +0000)
src/lua/lua_task.c

index f79de9b9298dac1c920a4fd2f229829202c0a4d5..c59ae33dc619d41b7a29c37707a433e75f4686dd 100644 (file)
@@ -27,6 +27,7 @@
 #include "cryptobox.h"
 #include "unix-std.h"
 #include "libmime/smtp_parsers.h"
+#include <math.h>
 
 /***
  * @module rspamd_task
@@ -3159,7 +3160,7 @@ lua_task_get_metric_score (lua_State *L)
                if ((metric_res =
                        g_hash_table_lookup (task->results, metric_name)) != NULL) {
                        lua_createtable (L, 2, 0);
-                       lua_pushnumber (L, metric_res->score);
+                       lua_pushnumber (L, isnan (metric_res->score) ? 0.0 : metric_res->score);
                        rs = rspamd_task_get_required_score (task, metric_res);
                        lua_rawseti (L, -2, 1);
                        lua_pushnumber (L, rs);