I don’t think it contradicts the CCC either. However, only because of the extreme nature of the discussion as defined by the OP (on the verge of death). However, this is the extreme and I was concerned that this could/would be interpreted to mean it was ok in the less extreme as it opens up a can of worms that I don’t think St. Thomas or the CCC intends to condone- taking to relieve even extreme discomfort (as opposed to extreme suffering- there is a difference).
But, I do think that St. Thomas’ words about not being bound to restitution if the taken item was perishable can also be misinterpreted. I read the words to say that a starving man would not have to make restitution if the taken item would have become useless to the owner if the starving man had not consumed the food. But unless one looks at it carefully, a starving man who has to kill a cow to save himself would be bound to make at least an attempt at restitution, especially if his economic condition improved. Taking an apple about to rot is different than killing a cow to satisfy immediate hunger.