Explorar o código

Check return value on write of raw pointer

Felix Jendrusch %!s(int64=7) %!d(string=hai) anos
pai
achega
1da9ffe394
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      objectivec/GPBCodedOutputStream.m

+ 4 - 1
objectivec/GPBCodedOutputStream.m

@@ -942,7 +942,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
       state_.position = length;
     } else {
       // Write is very big.  Let's do it all at once.
-      [state_.output write:((uint8_t *)value) + offset maxLength:length];
+      NSInteger written = [state_.output write:((uint8_t *)value) + offset maxLength:length];
+      if (written != (NSInteger)length) {
+        [NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""];
+      }
     }
   }
 }