From db47c44565b443d8f1cb1280061762a7bc607a86 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Fri, 4 Mar 2016 00:40:39 +0000 Subject: Do not segfault on comments with invalid UTF-8 --- giscanner/giscannermodule.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c index cd0718e4..4c1f00f3 100644 --- a/giscanner/giscannermodule.c +++ b/giscanner/giscannermodule.c @@ -631,6 +631,12 @@ pygi_source_scanner_get_comments (PyGISourceScanner *self) if (comment->comment) { comment_obj = PyUnicode_FromString (comment->comment); + if (!comment_obj) + { + g_print ("Comment is not valid Unicode in %s line %d\n", comment->filename, comment->line); + Py_INCREF (Py_None); + comment_obj = Py_None; + } } else { -- cgit v1.2.1