This is an outright lie. It has NEVER happened that a business has been sued for donating food. Not once. It's just a convenient excuse for saying '%$@# the poor.'
If no business transaction has been formalized then why should either party be liable? Indeed, if a person is not permitted to simply say "this is the software I am using" without also becoming liable for problems caused when other people use or look at that software? I don't think it is right to allow a person to be liable just for the speech of their software.
Fortunately, a lot of open source software is known to be open source because of a license file. Many open source licenses declare no liability or warranty of any kind. In that case, would not any liability claimed would be forfeit? Otherwise they would have been using the software in breach of its declared intended purpose at the point of time being talked about.
Every person has a duty of care to minimize the possibility of harm to others. In some professions the standard is higher and may be codified into statute and/or bylaws of their professional association e.g. medical and legal professions. What this means is that, for example, in certain jurisdictions a doctor is bound by his Hippocratic oath and has to render medical assistance to a person who is in urgent need of it, as quickly as practicable. Ignoring this exposes him to liability. So in the particular case of software, a malware author could in theory be found liable by posting his proof of concept in the public domain.
Secondly, in certain jurisdictions, there is an implied warranty of merchantability and also of fitness for a particular purpose. In the US this is under the Uniform Commercial Code.
The example you cite of a doctor being required to provide emergency medical care I don’t think is quite accurate. In fact, doctors are often not covered by “Good Samaritan” laws and can be held liable if they do stop to help someone and something goes wrong. A layperson would not have that type of legal exposure. Medical treatment issues are complex and I can’t see how they are related to open source software.
In the U.S., a doctor has no affirmative duty to provide medical assistance to injured persons if they have not established a special relationship with the individual.
https://en.m.wikipedia.org/wiki/Duty_to_rescue
Read the last part about the elderly man who died in a bank and no one offered assistance.
Citation? That doesn't seem right, based on my anecdotal knowledge that restaurants take care to throw leftovers into a garbage bin rather than leave them out somewhere where someone could eat them and expose the business to liability.
I looked up this claim myself. In 1996, President Clinton signed the Good Samaritan Food Donation Act into law to limit liability for those who donate food. [1] The majority of restaurants still discard leftover food due to concerns over liability, though. [2] Clearly, liability was a real issue at some point in the past. I don't know enough about the current law to know how easy it is to take advantage of the new protections; I can understand why people are still concerned.
In summary, liability issues vary by country and are not clear-cut. As an analogy for this open-source situation, they don't clarify matters.
[1] https://digitalcommons.law.seattleu.edu/cgi/viewcontent.cgi?...
[2] https://www.huffingtonpost.com/entry/restaurants-that-dont-d...