From 9184a8b046efdfd95db127cac03475fc9b2ccfd6 Mon Sep 17 00:00:00 2001
From: Michael Carlberg <c@rlberg.se>
Date: Thu, 12 Jan 2017 20:25:57 +0100
Subject: [PATCH] fix(memory): Safety check

---
 src/modules/memory.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp
index 3aa9ae9a..eeb782b1 100644
--- a/src/modules/memory.cpp
+++ b/src/modules/memory.cpp
@@ -47,7 +47,9 @@ namespace modules {
 
       while (std::getline(in, str) && i++ < 3) {
         size_t off = str.find_first_of("1234567890", str.find(':'));
-        buffer << std::strtol(&str[off], nullptr, 10) << std::endl;
+        if (off != string::npos && str.size() > off) {
+          buffer << std::strtol(&str[off], nullptr, 10) << std::endl;
+        }
       }
 
       buffer >> rdbuf;