szaszm commented on a change in pull request #848:
URL: https://github.com/apache/nifi-minifi-cpp/pull/848#discussion_r463077312



##########
File path: extensions/expression-language/Expression.cpp
##########
@@ -194,9 +194,12 @@ Value expr_toLower(const std::vector<Value> &args) {
 
 Value expr_substring(const std::vector<Value> &args) {
   if (args.size() < 3) {
-    return Value(args[0].asString().substr(args[1].asUnsignedLong()));
+    size_t offset = gsl::narrow<size_t>(args[1].asUnsignedLong());
+    return Value(args[0].asString().substr(offset));
   } else {
-    return Value(args[0].asString().substr(args[1].asUnsignedLong(), 
args[2].asUnsignedLong()));
+    size_t offset = gsl::narrow<size_t>(args[1].asUnsignedLong());
+    size_t count = gsl::narrow<size_t>(args[2].asUnsignedLong());
+    return Value(args[0].asString().substr(offset, count));

Review comment:
       :+1: for naming the integers




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to