db_fetch_object returning null
Actually, db_fetch_object() could also return NULL, contrary to what the documentation says. The documentation assumes you aren't passing to the function a value that for PHP is equivalent to FALSE, for example NULL, an empty array, or an uninitialized variable. If the function gets a value that for PHP is equivalent to FALSE, the function will not execute any instruction, and it will return NULL.
function db_fetch_object($result) {
  if ($result) {
    return mysql_fetch_object($result);
  }
}

The same is true for other database engines, for example PostgreSQL, which uses the following function.
function db_fetch_object($result) {
  if ($result) {
    return pg_fetch_object($result);
  }
}

This is usually not a problem, since the function should normally be called as in the following snippets.
 if ($category = db_fetch_object(db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = %d', $id))) {
    $block['subject'] = check_plain($category-&gt;title);
    $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = %d ORDER BY i.timestamp DESC, i.iid DESC', $category-&gt;cid, 0, $category-&gt;block);
    $read_more = theme('more_link', url('aggregator/categories/' . $category-&gt;cid), t(&quot;View this category's recent news.&quot;));
  }


  while ($item = db_fetch_object($result)) {
    $items[] = theme('aggregator_block_item', $item);
  }

In both the cases, the control statements will not be executed, since for them NULL is equivalent to FALSE.