ggettext: add some comments

Coverity has improperly flagged this code as an instance of CWE-562. The
code is fine, but it's confusing, and humans are likely to wind up
examining it again in the future, so add some comments to explain what's
up.
This commit is contained in:
Michael Catanzaro 2024-08-22 12:48:00 -05:00
parent 2a4ace34b0
commit d95880af93

View File

@ -237,6 +237,10 @@ g_dpgettext (const gchar *domain,
translation = g_dgettext (domain, tmp);
/* g_dgettext() may return the value we pass to it, which will be on
* this stack frame since we allocated it with g_alloca(). If so, we
* return a pointer into our original input instead.
*/
if (translation == tmp)
return sep + 1;
}
@ -294,6 +298,10 @@ g_dpgettext2 (const gchar *domain,
msg_ctxt_id[msgctxt_len - 1] = '|';
translation = g_dgettext (domain, msg_ctxt_id);
/* g_dgettext() may return the value we pass to it, which will be on this
* stack frame since we allocated it with g_alloca(). If so, we return our
* original input instead.
*/
if (translation == msg_ctxt_id)
return msgid;
}