Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/Vulkan-Loader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2022-03-17 21:08:49 +0300
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-03-21 23:04:39 +0300
commitd24fa72f1463c978da04d399468b10001fbc59a7 (patch)
tree665f0332b6afc1119aa635f2db44f9686350dbaf
parent010b23a1aee06645d1a2c610d4224027bfece366 (diff)
More clean up to make sure we have enough space
-rw-r--r--loader/log.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/loader/log.c b/loader/log.c
index 49ce951e2..6b68bd0dc 100644
--- a/loader/log.c
+++ b/loader/log.c
@@ -208,23 +208,24 @@ void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t ms
num_used++;
}
- if (num_used) {
+ size_t available_space = cmd_line_size - num_used;
+ if (available_space > 0) {
// If the message is too long, trim it down
- if (strlen(msg) > cmd_line_size) {
- msg[cmd_line_size - 1] = '\0';
+ if (strlen(msg) > available_space) {
+ msg[available_space - 1] = '\0';
}
strncat(cmd_line_msg, msg, cmd_line_size);
+
+#if defined(WIN32)
+ OutputDebugString(cmd_line_msg);
+ OutputDebugString("\n");
+#endif
+
+ fputs(cmd_line_msg, stderr);
+ fputc('\n', stderr);
} else {
// Shouldn't get here, but check to make sure if we've already overrun
// the string boundary
assert(false);
}
-
-#if defined(WIN32)
- OutputDebugString(cmd_line_msg);
- OutputDebugString("\n");
-#endif
-
- fputs(cmd_line_msg, stderr);
- fputc('\n', stderr);
}