about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/derivations.cc
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-08-03T14·47-0700
committerkanepyork <rikingcoding@gmail.com>2020-08-05T02·54+0000
commitb15b447fcb25fc6232a61cbe5c869fa473c12efc (patch)
treed04c96e158978be5b697823c6056b63415e96a1a /third_party/nix/src/libstore/derivations.cc
parent418f98fe7254fb4aa879b47e427d930a9ccbb5d6 (diff)
fix(3p/nix): fix clang-tidy for int-string appends r/1593
Change-Id: I276de7a5fd1c705c87d35dd616e5980c747190aa
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1597
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix/src/libstore/derivations.cc')
-rw-r--r--third_party/nix/src/libstore/derivations.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index 978d39b94e7d..007c268bab2a 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -3,6 +3,7 @@
 #include <absl/strings/match.h>
 #include <absl/strings/str_split.h>
 #include <absl/strings/string_view.h>
+#include <glog/logging.h>
 
 #include "libstore/fs-accessor.hh"
 #include "libstore/globals.hh"
@@ -97,7 +98,7 @@ static std::string parseString(std::istream& str) {
   std::string res;
   expect(str, "\"");
   int c;
-  while ((c = str.get()) != '"') {
+  while ((c = str.get()) != '"' && c != EOF) {
     if (c == '\\') {
       c = str.get();
       if (c == 'n') {
@@ -106,11 +107,13 @@ static std::string parseString(std::istream& str) {
         res += '\r';
       } else if (c == 't') {
         res += '\t';
+      } else if (c == EOF) {
+        throw FormatError("unexpected EOF while parsing C-style escape");
       } else {
-        res += c;
+        res += static_cast<char>(c);
       }
     } else {
-      res += c;
+      res += static_cast<char>(c);
     }
   }
   return res;