summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2022-05-10 16:38:44 +0100
committerPhilip Withnall <pwithnall@endlessos.org>2022-05-10 16:38:44 +0100
commitecbc52c9845fb3a4f1552cda4df2bff191f2c7b1 (patch)
tree20bdb841e97a487d72999796488ee3dc20bcc46e
parent95e31875b257058e482342095c72050e4ed56ae3 (diff)
xdgmimemagic: Add an assertion to clarify state after hitting an error
This introduces no functional changes, but should help guide static analysis. Currently, scan-build thinks that `match` could be used after being freed, because it assumes that `_xdg_mime_magic_parse_error()` could return any `XdgMimeMagicState`. See the trace here: https://gnome.pages.gitlab.gnome.org/-/glib/-/jobs/1993739/artifacts/_scan_build/meson-logs/scanbuild/2022-05-10-050755-3977-1/report-6f5f44.html#EndPath Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--src/xdgmimemagic.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/xdgmimemagic.c b/src/xdgmimemagic.c
index ddf4efb..c17aaf0 100644
--- a/src/xdgmimemagic.c
+++ b/src/xdgmimemagic.c
@@ -798,6 +798,11 @@ _xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic,
break;
case XDG_MIME_MAGIC_ERROR:
state = _xdg_mime_magic_parse_error (magic_file);
+
+ /* After a parse error we can only be at EOF or reset to starting a
+ * new section. */
+ assert (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_SECTION);
+
break;
case XDG_MIME_MAGIC_EOF:
default: