In some cases (if profiles in complain and enforce mode are loaded), the i
loop runs more
than once, which also means j == 0
is true in the middle of the json.
This causes invalid json.
This patch fixes this.
This is a regression related to 22aa9b61 / !964 (merged) / #295 (closed) which fixed another case of invalid json if a process was unconfined while having a profile defined.
Note: I also tested this patch for the "unconfined, but has a profile defined" case to ensure it doesn't break what 22aa9b61 fixed.
This fix is needed in all branches that also got !964 (merged) (which means 3.1 and 3.0).