diff --git a/steam-runtime-tools/runtime.c b/steam-runtime-tools/runtime.c
index 324ae7e2f04012ae76f0f9ebc140aa3a10ba0210..d690d0601324cd8f6c129e9e22806dff7a0e936d 100644
--- a/steam-runtime-tools/runtime.c
+++ b/steam-runtime-tools/runtime.c
@@ -234,7 +234,7 @@ _srt_runtime_check (const char *bin32,
       const char *underscore = strrchr (contents, '_');
 
       /* Remove trailing \n if any */
-      if (contents[len - 1] == '\n')
+      if (len > 0 && contents[len - 1] == '\n')
         contents[--len] = '\0';
 
       if (len != strlen (contents) ||