Mozilla Thunderbird


BUG OF THE MONTH | Idempotent loop

V1044 Loop break conditions do not depend on the number of iterations. mimemoz2.cpp 1795

void ResetChannelCharset(MimeObject *obj) {
  if (cSet) {
    char *ptr2 = cSet;
    while ((*cSet) && (*cSet != ' ') && (*cSet != ';') &&
           (*cSet != '\r') && (*cSet != '\n') && (*cSet != '"'))
    if (*cSet) {
      obj->options->default_charset = strdup(cSet);
      obj->options->override_charset = true;

This error is found using a new diagnostic that will be available in the next analyzer release. All variables used in the while loop’s condition don’t change, as variables ptr2 and cSet are confused in the body of the function.

Please click here to see more bugs from this project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.