In Bava Kama (60:):
ויתאוה דוד ויאמר מי ישקני מים מבור בית לחם אשר בשער ויבקעו שלשת הגבורים במחנה פלשתים וישאבו מים מבור בית לחם אשר בשער [וגו'] מאי קא מיבעיא ליה אמר רבא אמר ר"נ טמון באש קמיבעיא ליה אי כר' יהודה אי כרבנן ופשטו ליה מאי דפשטו ליה רב הונא אמר גדישים דשעורים דישראל הוו דהוו מטמרי פלשתים בהו וקא מיבעיא ליה מהו להציל עצמו בממון חבירו שלחו ליה אסור להציל עצמו בממון חבירו אבל אתה מלך אתה [ומלך] פורץ לעשות לו דרך ואין מוחין בידו ורבנן ואיתימא רבה בר מרי אמרו גדישים דשעורין דישראל הוו וגדישין דעדשים דפלשתים וקא מיבעיא להו מהו ליטול גדישין של שעורין דישראל ליתן לפני בהמתו על מנת לשלם גדישין של עדשים דפלשתים שלחו ליה (יחזקאל לג, טו) חבול ישיב רשע גזילה ישלם אע"פ שגזילה משלם רשע הוא אבל אתה מלך אתה ומלך פורץ לעשות לו דרך ואין מוחין בידו בשלמא למאן דאמר לאחלופי היינו דכתיב חד קרא (שמואל ב כג, יא) ותהי שם חלקת השדה מלאה עדשים וכתיב חד קרא (דברי הימים א יא, יג) ותהי חלקת השדה מלאה שעורים אלא למאן דאמר למקלי מאי איבעיא להו להני תרי קראי אמר לך דהוו נמי גדישים דעדשים דישראל דהוו מיטמרו בהו פלשתים בשלמא למאן דאמר למקלי היינו דכתיב (שמואל ב כג, יב) ויתיצב בתוך החלקה ויצילה אלא למ"ד לאחלופי מאי ויצילה דלא שבק להו לאחלופי
The Gemara continues with another statement of aggada on a related topic: The verse states: “And David longed, and said: Oh, that one would give me water to drink of the well of Bethlehem, which is by the gate! And the three mighty men broke through the host of the Philistines, and drew water out of the well of Bethlehem, that was by the gate, and took it, and brought it to David; but he would not drink it, but poured it out to the Lord” (II Samuel 23:15–16). The Sages understood that David was not simply asking for water, but was using the term as a metaphor referring to Torah, and he was raising a halakhic dilemma. What is the dilemma that David is raising? Rava says that Rav Naḥman says: He was asking about the halakha with regard to a concealed article damaged by a fire. He wanted to know whether the halakha is in accordance with the opinion of Rabbi Yehuda, who holds that one is liable to pay for such damage, or whether the halakha is in accordance with the opinion of the Rabbis, who hold that one is exempt from liability for damage by fire to concealed articles. And the Sages in Bethlehem answered him what they answered him. Rav Huna stated a different explanation of the verse: There were stacks of barley belonging to Jews in which the Philistines were hiding, and David wanted to burn down the stacks to kill the Philistines and save his own life. He raised the dilemma: What is the halakha? Is it permitted to save oneself by destroying the property of another? They sent the following answer to him: It is prohibited to save oneself by destroying the property of another. But you are king, and a king may breach the fence of an individual in order to form a path for himself, and none may protest his action, i.e., the normal halakhot of damage do not apply to you since you are king. The Rabbis, and some say that it was Rabba bar Mari, give an alternative explanation of the dilemma and said: The stacks of barley belonged to Jews, and there were stacks of lentils belonging to the Philistines. David needed barley to feed his animals. And David raised the following dilemma: What is the halakha? I know that I may take the lentils belonging to a gentile to feed my animals, but is it permitted to take a stack of barley belonging to a Jew, to place before one’s animal for it to consume, with the intent to pay the owner of the barley with the stacks of lentils belonging to the Philistines? The Sages of Bethlehem sent the following reply to him: “If the wicked restore the pledge, give back that which he had taken by robbery, walk in the statutes of life, committing no iniquity; he shall surely live, he shall not die” (Ezekiel 33:15). This verse teaches that even though the robber repays the value of the stolen item, he is nevertheless considered to be wicked, and is described as such in the verse, and a commoner would not be allowed to act as you asked. But you are king, and a king may breach the fence of an individual in order to form a path for himself, and none may protest his action.... Granted, according to the one who says that David asked his question because he wanted to burn the stacks, this is as it is written in the following verse with regard to David: “But he stood in the midst of the plot, and saved it, and slew the Philistines; and the Lord performed a great victory” (II Samuel 23:12). But according to the one who says that David’s question was asked with regard to exchanging the lentils for the barley, what is the meaning of the phrase: “And saved it”? The Rabbis answer that David saved it in that he did not permit them to exchange the value of the barley with the lentils.
Tosafos on the Gemara:
מהו להציל עצמו בממון חבירו - איבעיא ליה אי חייב לשלם כשהציל עצמו מפני פקוח נפש:
"What is the halacha- Is it permitted to save oneself by destroying the property of another?" He asked him if he is obligated to pay after saving his own life
(All originals, and Gemara translation from Sefaria, Tosafos translation is my own.)
The Tosafos seems to imply that one can save his life with another's property, but (according to what the Gemara rules) must pay it back, but a king need not pay back. Yet we see that David not only decided to forgo his rights of not paying the owner back, he actually actively stops his soldiers from burning the field down- something even a commoner is allowed to do- thereby saving the field and endangering his own life!
So why, according to Tosafos, did David stop his soldiers from burning the field down, when even a commoner would be allowed to burn it down in this case?