You didn't say what almost caused the fire - damaged cord, or was it a socket or plug on one of the devices?
The most common cause of overheated connections is being loose, either the wiring to the socket, or the metal fingers inside the socket losing their tension and causing a resistive connection. Lower on the list would be corrosion or other damage like a plug that's been flexed a lot and internal wire strands are broken.
I tested this just a couple weeks ago as I anticipated using a heater just like the one in your photo. I plugged it into the RV's bedroom outlet with a short appliance extension cord (not a basic lamp cord) and left it on high for about 15 minutes. I felt the connections to see which ones were warm, and none were more than barely warmer than when they were off. So I deemed the connections good enough and used this heater for several days, often running for hours straight without incident. You will see cautions with heaters to inspect plugs and sockets before using them, and if they are loose or appear overheated you stop right there. The only remedy is to replace the offending sockets or plugs, which is neither difficult or expensive.
Mark B.
Albuquerque, NM