aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-17 18:19:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-17 18:19:18 +0100
commit3351b30b969716f83d9166025c6d940e7eedde5f (patch)
treecd8f11524a1c0609002e70a45a4c736e68676827
parentc0d2f5b0c3da61cbb03de38bc59b6c5279366428 (diff)
downloadrspamd-3351b30b969716f83d9166025c6d940e7eedde5f.tar.gz
rspamd-3351b30b969716f83d9166025c6d940e7eedde5f.zip
[Minor] Do not use floating point when extending buffers
-rw-r--r--src/client/rspamdclient.c2
-rw-r--r--src/libmime/archives.c2
-rw-r--r--src/libserver/task.c2
-rw-r--r--src/libutil/map.c8
-rw-r--r--src/lua/lua_util.c2
-rw-r--r--src/rspamd_proxy.c2
6 files changed, 9 insertions, 9 deletions
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c
index 7b1bcb73e..b8e89fcd7 100644
--- a/src/client/rspamdclient.c
+++ b/src/client/rspamdclient.c
@@ -187,7 +187,7 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn,
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2;
zout.dst = g_realloc (zout.dst, zout.size);
}
}
diff --git a/src/libmime/archives.c b/src/libmime/archives.c
index f3ad60067..d938dbcf3 100644
--- a/src/libmime/archives.c
+++ b/src/libmime/archives.c
@@ -1439,7 +1439,7 @@ rspamd_7zip_ucs2_to_utf8 (struct rspamd_task *task, const guchar *p,
UChar32 wc;
UBool is_error = 0;
- res = g_string_sized_new ((end - p) * 1.5 + sizeof (wc) + 1);
+ res = g_string_sized_new ((end - p) * 3 / 2 + sizeof (wc) + 1);
up = (guint16 *)p;
while (src_pos < len) {
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 3756e7c63..884489821 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -593,7 +593,7 @@ rspamd_task_load_message (struct rspamd_task *task,
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2 + 1;
zout.dst = g_realloc (zout.dst, zout.size);
}
}
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 123d31c5f..02e3913a4 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -456,7 +456,7 @@ http_map_finish (struct rspamd_http_connection *conn,
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2 + 1.0;
out = g_realloc (zout.dst, zout.size);
zout.dst = out;
}
@@ -835,7 +835,7 @@ read_map_file (struct rspamd_map *map, struct file_map_data *data,
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2 + 1;
out = g_realloc (zout.dst, zout.size);
zout.dst = out;
}
@@ -922,7 +922,7 @@ read_map_static (struct rspamd_map *map, struct static_map_data *data,
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2 + 1;
out = g_realloc (zout.dst, zout.size);
zout.dst = out;
}
@@ -1201,7 +1201,7 @@ rspamd_map_read_cached (struct rspamd_map *map, struct rspamd_map_backend *bk,
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2 + 1;
out = g_realloc (zout.dst, zout.size);
zout.dst = out;
}
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 0057dc472..461130157 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -2211,7 +2211,7 @@ lua_util_zstd_decompress (lua_State *L)
if (zin.pos < zin.size && zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2;
out = g_realloc (zout.dst, zout.size);
zout.dst = out;
}
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index dbf905609..66ab623f8 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -1144,7 +1144,7 @@ proxy_request_decompress (struct rspamd_http_message *msg)
if (zout.pos == zout.size) {
/* We need to extend output buffer */
- zout.size = zout.size * 1.5 + 1.0;
+ zout.size = zout.size * 2 + 1;
body = rspamd_fstring_grow (body, zout.size);
zout.size = body->allocated;
zout.dst = body->str;