@@ -80,7 +80,7 @@ Test(filterx_string, test_string_taking_a_short_slice_of_another_string)
8080 FilterXObject * str2 = filterx_string_new_slice (str , 1 , 3 );
8181
8282 assert_object_json_equals (str2 , "\"bc\"" );
83- cr_assert ((str2 -> flags & FILTERX_STRING_FLAG_STR_BORROWED_SLICE ) == 0 );
83+ cr_assert ((str2 -> flags & FILTERX_STRING_FLAG_STR_INDIRECT ) == 0 );
8484 filterx_object_unref (str2 );
8585 filterx_object_unref (str );
8686}
@@ -91,7 +91,7 @@ Test(filterx_string, test_string_taking_a_long_slice_of_another_string)
9191 FilterXObject * str2 = filterx_string_new_slice (str , 1 , 15 );
9292
9393 assert_object_json_equals (str2 , "\"123456789abcde\"" );
94- cr_assert ((str2 -> flags & FILTERX_STRING_FLAG_STR_BORROWED_SLICE ) != 0 );
94+ cr_assert ((str2 -> flags & FILTERX_STRING_FLAG_STR_INDIRECT ) != 0 );
9595 filterx_object_unref (str2 );
9696 filterx_object_unref (str );
9797}
@@ -107,6 +107,30 @@ Test(filterx_string, test_string_taking_an_cached_string_slice_results_in_a_cach
107107 filterx_object_unref (str );
108108}
109109
110+ Test (filterx_string , test_string_slice_propagates_nvtable_backed_marking )
111+ {
112+ /* simulate a value pulled from the message NVTable (the marking is normally
113+ * done by filterx_extract_object_from_logmsg(), not by the constructor) */
114+ FilterXObject * nvtable_backed = filterx_string_new_indirect ("0123456789abcdef" , 16 );
115+ nvtable_backed -> is_nvtable_backed = TRUE;
116+
117+ /* a slice of an NVTable-backed string is itself NVTable-backed */
118+ FilterXObject * slice = filterx_string_new_slice (nvtable_backed , 1 , 15 );
119+ cr_assert (filterx_object_is_nvtable_backed (slice ));
120+
121+ /* a slice of a self-owned string is not NVTable-backed, even though it
122+ * borrows the payload */
123+ FilterXObject * owned = filterx_string_new_take (g_strdup ("0123456789abcdef" ), 16 );
124+ FilterXObject * owned_slice = filterx_string_new_slice (owned , 1 , 15 );
125+ cr_assert (!filterx_object_is_nvtable_backed (owned_slice ));
126+ cr_assert ((owned_slice -> flags & FILTERX_STRING_FLAG_STR_INDIRECT ) != 0 );
127+
128+ filterx_object_unref (slice );
129+ filterx_object_unref (nvtable_backed );
130+ filterx_object_unref (owned_slice );
131+ filterx_object_unref (owned );
132+ }
133+
110134static void
111135_translate_to_incremented (gchar * target , const gchar * source , gsize * len )
112136{
0 commit comments