Language: C
Label: safe
CWE: CWE-835 \u2014 Loop with Unreachable Exit Condition ('Infinite Loop')
The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.

Code:
_pdfioDictRead(pdfio_file_t   *pdf,	// I - PDF file
               pdfio_obj_t    *obj,	// I - Object, if any
               _pdfio_token_t *tb,	// I - Token buffer/stack
               size_t         depth)	// I - Depth of dictionary
{
  pdfio_dict_t		*dict;		// New dictionary
  char			key[256];	// Dictionary key
  _pdfio_value_t	value;		// Dictionary value


  PDFIO_DEBUG("_pdfioDictRead(pdf=%p)\n", pdf);

  // Create a dictionary and start reading...
  if ((dict = pdfioDictCreate(pdf)) == NULL)
    return (NULL);

  while (_pdfioTokenGet(tb, key, sizeof(key)))
  {
    // Get the next key or end-of-dictionary...
    if (!strcmp(key, ">>"))
    {
      // End of dictionary...
      return (dict);
    }
    else if (key[0] != '/')
    {
      _pdfioFileError(pdf, "Invalid dictionary contents.");
      break;
    }
    else if (_pdfioDictGetValue(dict, key + 1))
    {
      _pdfioFileError(pdf, "Duplicate dictionary key '%s'.", key + 1);
      return (NULL);
    }

    // Then get the next value...
    PDFIO_DEBUG("_pdfioDictRead: Reading value for '%s'.\n", key + 1);

    if (!_pdfioValueRead(pdf, obj, tb, &value, depth))
    {
      _pdfioFileError(pdf, "Missing value for dictionary key.");
      break;
    }

    if (!_pdfioDictSetValue(dict, pdfioStringCreate(pdf, key + 1), &value))
      break;

//    PDFIO_DEBUG("_pdfioDictRead: Set %s.\n", key);
  }

  // Dictionary is invalid - pdfioFileClose will free the memory, return NULL
  // to indicate an error...
  return (NULL);
}