From 1008f26c7c6855f59222bcbe2cd1505ba8a6f28f Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 31 Mar 2014 04:24:10 +0200
Subject: [PATCH] Make textfile_width() check for too large lines.

---
 TODO                   | 2 --
 src/common/readwrite.c | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/TODO b/TODO
index 42c0e9a..16d126b 100644
--- a/TODO
+++ b/TODO
@@ -9,8 +9,6 @@ BOTH SERVER/CLIENT:
 
 - be more strict and humble when allocating memory from the stack
 
-- in textfield_width(), handle too large lines somehow
-
 - may err_line store the processed line internally as it does the line count
 
 SERVER:
diff --git a/src/common/readwrite.c b/src/common/readwrite.c
index a0ab3f7..3dcd2a2 100644
--- a/src/common/readwrite.c
+++ b/src/common/readwrite.c
@@ -2,7 +2,7 @@
 
 #include "readwrite.h"
 #include <stddef.h> /* size_t */
-#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
+#include <stdint.h> /* uint8_t, uint16_t, uint32_t, UINT32_MAX */
 #include <stdio.h> /* FILE, fseek(), sprintf(), fgets(), fgetc(), ferror(),
                     * fputc(), fwrite(), fclose(), fopen()
                     */
@@ -108,6 +108,7 @@ extern uint32_t textfile_width(FILE * file)
         {
             break;
         }
+        exit_trouble(UINT32_MAX == c_count, f_name, "too large text file line");
         c_count++;
         if ('\n' == c)
         {
-- 
2.30.2