diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a6a509e7..cbc99cddc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix preference ID in "Host Discovery" config [#828](https://github.com/greenbone/gvmd/pull/828)
- Fix order of fingerprints in get_tls_certificates [#833](https://github.com/greenbone/gvmd/pull/833)
- Update config preferences after updating NVTs [#832](https://github.com/greenbone/gvmd/pull/832)
+- Fix notes XML for lean reports [#836](https://github.com/greenbone/gvmd/pull/836)
### Removed
diff --git a/src/gmp.c b/src/gmp.c
index d8f36e2c6..3038c7c63 100644
--- a/src/gmp.c
+++ b/src/gmp.c
@@ -9928,6 +9928,8 @@ buffer_result_notes_xml (GString *buffer, result_t result, task_t task,
{
get_data_t get;
iterator_t notes;
+ GString *temp_buffer;
+
memset (&get, '\0', sizeof (get));
/* Most recent first. */
get.filter = "sort-reverse=created owner=any permission=any";
@@ -9941,15 +9943,20 @@ buffer_result_notes_xml (GString *buffer, result_t result, task_t task,
result,
task);
- if (lean == 0 || next (¬es))
- g_string_append (buffer, "");
- buffer_notes_xml (buffer,
+ temp_buffer = g_string_new ("");
+ buffer_notes_xml (temp_buffer,
¬es,
include_notes_details,
0,
NULL);
- if (lean == 0 || next (¬es))
- g_string_append (buffer, "");
+
+ if (lean == 0 || strlen (temp_buffer->str))
+ {
+ g_string_append (buffer, "");
+ g_string_append (buffer, temp_buffer->str);
+ g_string_append (buffer, "");
+ }
+ g_string_free (temp_buffer, TRUE);
cleanup_iterator (¬es);
}