Merge: lib/core: Fix substring issue in `ASCIIFlatString`
authorJean Privat <jean@pryen.org>
Tue, 17 May 2016 20:17:32 +0000 (16:17 -0400)
committerJean Privat <jean@pryen.org>
Tue, 17 May 2016 20:17:32 +0000 (16:17 -0400)
commit2f2bafbc9a527d8d8e95c8a0a5994902aaff2108
tree257478318351364c0aa2384175eaab1682af8426
parentd80492bba2d20142f40f5409bc7e4bbce9a1dca0
parente9a074d94ce5441727e2d90aba847bc5f8fbeac3
Merge: lib/core: Fix substring issue in `ASCIIFlatString`

A bug in the validation part of `ASCIIFlatString::substring` caused some substrings to be created with a negative length, which could be the cause of various negative side-effects.

In the example added in the substring test, this caused `stdout` to close due to a call to `fwrite` with a negative count, which was in turn converted to unsigned (I suspect this is undefined behaviour), provoking the closure of the stream in the nit part.

Reported by @Morriar
Close #2089

Pull-Request: #2091
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>