From e6b7840265f17e8934500815030a2fc0553feb81 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 30 Aug 2013 10:21:16 +0200
Subject: [PATCH] Corrected window title creation.

---
 src/main.c       | 2 +-
 src/wincontrol.c | 3 ++-
 src/windows.c    | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index bbc4302..0ecc10a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
     world.score = 0;
     world.log = calloc(1, sizeof(char));
     set_cleanup_flag(CLEANUP_LOG);
-    update_log (&world, " ");
+    update_log(&world, " ");
     struct Player player;
     player.hitpoints = 5;
     world.player = &player;
diff --git a/src/wincontrol.c b/src/wincontrol.c
index 715aebb..793b75e 100644
--- a/src/wincontrol.c
+++ b/src/wincontrol.c
@@ -43,7 +43,8 @@ extern struct Win * init_win_from_file(struct World * world, char * w_name,
     err = "Trouble in init_win_from_file() with fgets().";
     exit_err(NULL == fgets(line, linemax, file), world, err);
     char * title = malloc(strlen(line));
-    memcpy(title, line, strlen(line) - 1);
+    memcpy(title, line, strlen(line) - 1);   /* Eliminate newline char at end */
+    title[strlen(line) - 1] = '\0';          /* of string.                    */
     exit_err(NULL == fgets(line, linemax, file), world, err);
     int16_t height = atoi(line);
     exit_err(NULL == fgets(line, linemax, file), world, err);
diff --git a/src/windows.c b/src/windows.c
index af710dd..bb78a8b 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -400,7 +400,7 @@ extern uint8_t init_win(struct WinMeta * wmeta, struct Win * w, char * title,
     {
         return 1;
     }
-    sprintf(w->_title, title, strlen(title));
+    sprintf(w->_title, "%s", title);
     w->data              = data;
     w->_draw             = func;
     if      (0 < width)
-- 
2.30.2