The methods that convert from a gunichar to a specific encoding may update the output 'clen' value unconditionally, regardless of whether the conversion is going to be successful or not. Avoid that by updating the length only if the conversion was successful. ---
Hey, Looks like we're updating the length unconditionally, even if the char conversion fails. This didn't have any implication in the logic because it looks like all the callers of this method just ignore the returned length (they're interested in the number of unsupported chars returned by reference). Maybe we should just update the method instead to return the number of unsupported chars instead and ignore the output length in the target encoding? --- src/mm-charsets.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mm-charsets.c b/src/mm-charsets.c index fb47b0ae..5cfb172e 100644 --- a/src/mm-charsets.c +++ b/src/mm-charsets.c @@ -627,7 +627,8 @@ mm_charset_get_encoded_len (const char *utf8, if (!e->func (c, p, (end - p), &clen)) unsupported++; - len += clen; + else + len += clen; p = end; } -- 2.13.3 _______________________________________________ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel