From 31859ff128acb87962cd078cba4796a71e45fcd5 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 16 Mar 2019 04:35:31 +0000 Subject: [PATCH] Fix Win32 build Windows std::ptrdiff_t is `int` instead of `long` as it should be. Expand the values out to `long` (which is the same size as `int` on Win32!) before printing them. This fixes format string warnings. Reported-by: Ninjared Fixes: 42a2e3ab0b420c3c7c4b7c3791525c0b15352462 ("Avoid crash loading polymodels with invalid subcalls") --- similar/3d/interp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/similar/3d/interp.cpp b/similar/3d/interp.cpp index b50ed7ac1..fb3517bc9 100644 --- a/similar/3d/interp.cpp +++ b/similar/3d/interp.cpp @@ -144,7 +144,10 @@ public: auto &opref = *wp(p); const auto badop = opref; opref = OP_EOF; - con_printf(CON_URGENT, "warning: %s:%u: invalid polymodel at %p with length %u; opcode %u at offset %li references invalid offset %li; replacing invalid operation with EOF", __FILE__, line, model_base, static_cast(model_length), badop, offset_from_base, offset_of_value); + const unsigned long uml = model_length; + const long ofb = offset_from_base; + const long oov = offset_of_value; + con_printf(CON_URGENT, "%s:%u: warning: invalid polymodel at %p with length %lu; opcode %u at offset %li references invalid offset %li; replacing invalid operation with EOF", __FILE__, line, model_base, uml, badop, ofb, oov); return 1; } return 0;