diff options
author | Jehan <jehan@girinstud.io> | 2018-11-13 14:51:35 +0100 |
---|---|---|
committer | Jehan <jehan@girinstud.io> | 2018-11-13 15:02:13 +0100 |
commit | 6a6afb9415922cec4b4c66691a24f23a5c2ea77d (patch) | |
tree | 337d7ec0ed57319ad0e265a411a0f31c5ed34183 /pango/break-thai.c | |
parent | 00afb8577f3aff2f5f8e1b8cd1f9a3da6c0421e4 (diff) | |
download | pango-6a6afb9415922cec4b4c66691a24f23a5c2ea77d.tar.gz |
pango: th_brk_new() may return NULL.
The call to th_brk_new() may return NULL, in case of allocation failure
of course, but also if the default dictionnary fails to load, which may
be an unlikely event, yet far from impossible (packaging may have
forgotten the file hence it may be absent, have been corrupted, or
whatever else).
In any case, although unlikely, it is not impossible, and should not
crash the whole program so we should check the return value and output a
warning if NULL.
Note that the call to th_brk_find_breaks() can still run even if brk is
NULL so we only check before freeing the data.
Diffstat (limited to 'pango/break-thai.c')
-rw-r--r-- | pango/break-thai.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pango/break-thai.c b/pango/break-thai.c index 4a6c4278..2ab24bd0 100644 --- a/pango/break-thai.c +++ b/pango/break-thai.c @@ -85,7 +85,11 @@ break_thai (const char *text, #ifdef HAVE_TH_BRK_FIND_BREAKS brk = th_brk_new(NULL); len = th_brk_find_breaks(brk, tis_text, brk_pnts, cnt); - th_brk_delete(brk); + if (brk) + th_brk_delete(brk); + else + g_warning ("%s: failed to load the default Thai word-breaker.", + G_STRLOC); #else G_LOCK (th_brk); len = th_brk (tis_text, brk_pnts, cnt); |