szaszm commented on a change in pull request #1036:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1036#discussion_r600419189
##########
File path: extensions/jni/jvm/JniReferenceObjects.h
##########
@@ -142,7 +142,7 @@ class JniByteInputStream : public
minifi::InputStreamCallback {
int read = 0;
do {
- int actual = (int) stream_->read(buffer_, remaining <= buffer_size_ ?
remaining : buffer_size_);
+ int actual = (int) stream_->read(buffer_,
gsl::narrow<uint64_t>(remaining) <= buffer_size_ ? remaining : buffer_size_);
Review comment:
In any of these cases, we need to add a precondition (`gsl_Expects`)
that `size` must not be negative, for the narrowing to be safe. I know that the
behavior is identical, but crashing because of narrowing error looks
accidental, while a precondition clearly communicates the intent.
--
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:
[email protected]