]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Do not use floating point when extending buffers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 17 Oct 2019 17:19:18 +0000 (18:19 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 17 Oct 2019 17:19:18 +0000 (18:19 +0100)
src/client/rspamdclient.c
src/libmime/archives.c
src/libserver/task.c
src/libutil/map.c
src/lua/lua_util.c
src/rspamd_proxy.c

index 7b1bcb73e59d95256fa71299ccb79b4bccc01830..b8e89fcd7c7ef2d114617936ba0ef49b217da87b 100644 (file)
@@ -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);
                                        }
                                }
index f3ad60067f69707fd03321cfed6ed2c522bfd700..d938dbcf3475678644a4ae46dd7f4aaea4152d9d 100644 (file)
@@ -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) {
index 3756e7c6301e26a8d7f6dc118ba3046c48ca087b..884489821620dfc77ea0d89cba07eca4522862c3 100644 (file)
@@ -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);
                                }
                        }
index 123d31c5f5117340491f769a06235a74e1e69e5d..02e3913a4986bdffb90912aff35e9e4964a42478 100644 (file)
@@ -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;
                        }
index 0057dc4722ed445a4904ee58af0916e503da4f1d..461130157f93d41f2d4ddd7e4bab1edb80e09fef 100644 (file)
@@ -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;
                }
index dbf90560987ee89f8aa2117e8ff362760c0b7806..66ab623f82d4c447ebb516a43bbe32cf9727f1e0 100644 (file)
@@ -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;