From b15b447fcb25fc6232a61cbe5c869fa473c12efc Mon Sep 17 00:00:00 2001 From: Kane York Date: Mon, 3 Aug 2020 07:47:07 -0700 Subject: fix(3p/nix): fix clang-tidy for int-string appends Change-Id: I276de7a5fd1c705c87d35dd616e5980c747190aa Reviewed-on: https://cl.tvl.fyi/c/depot/+/1597 Tested-by: BuildkiteCI Reviewed-by: glittershark --- third_party/nix/src/libstore/derivations.cc | 9 ++++++--- 1 file 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 #include #include +#include #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(c); } } else { - res += c; + res += static_cast(c); } } return res; -- cgit 1.4.1