]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix case when all words are exceptions
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 30 Nov 2018 15:02:39 +0000 (15:02 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 30 Nov 2018 15:02:39 +0000 (15:02 +0000)
src/libutil/shingles.c

index 2e05b773f5d7af98b56552e7671242f0cdac5fba..70aa5fe78682217ea3e9588dc47fe09dc4b4b2db 100644 (file)
@@ -176,6 +176,17 @@ rspamd_shingles_from_text (GArray *input,
                                                }
                                        }
 
+                                       if (word == NULL) {
+                                               /* Nothing but exceptions */
+                                               for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
+                                                       g_free (hashes[i]);
+                                               }
+
+                                               g_free (hashes);
+
+                                               return NULL;
+                                       }
+
                                        row = rspamd_fstring_append (row, word->stemmed.begin,
                                                        word->stemmed.len);
                                }
@@ -235,6 +246,17 @@ rspamd_shingles_from_text (GArray *input,
                                                }
                                        }
 
+                                       if (word == NULL) {
+                                               /* Nothing but exceptions */
+                                               for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
+                                                       g_free (hashes[i]);
+                                               }
+
+                                               g_free (hashes);
+
+                                               return NULL;
+                                       }
+
                                        /* Insert the last element to the pipe */
                                        memcpy (&seed, keys[j], sizeof (seed));
                                        window[j * SHINGLES_WINDOW + SHINGLES_WINDOW - 1] =