This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Enabling unit tests for MSVC compiler + fix MSVC compiler and static analyzer warnings#5
Open
alexey-malov wants to merge 19 commits intoalexa:masterfrom
Open
Enabling unit tests for MSVC compiler + fix MSVC compiler and static analyzer warnings#5alexey-malov wants to merge 19 commits intoalexa:masterfrom
alexey-malov wants to merge 19 commits intoalexa:masterfrom
Conversation
This fixes MSVC compiler warning
Variable `status` in a cycle shadows the `status` variable from the outer scope. I can omit shadowing by reusing the variable from the outer scope since it is not used after the cycle.
The `node` argument must be checked against NULL before it is dereferenced.
- Fix possible null pointer dereference in webvtt_proc_cueline function.
In cue argument must be checked against NULL
before it is dereferenced on lines 520 and 541.
Testing cue pointer for NULL on line 525 is too late.
- Fix `token` variable shadowin on line 608
- Fix possible problems in webvtt_read_cuetext function.
- In line 844 the assertion expression must check the value of self->top->type
instead of assigning it.
- Line 866: It is necessary check self->line_buffer.d for NULL because
it can be NULL due to check on line 852. Otherwise it is possible
to dereference a NULL pointer on line 889.
- Fix false positive code analyzer warning on possible intermediate result truncation on line 1067:
( ch - '0' ) produces 32-bit value which is then converted to 64 bit when added to `result * 10`.
Add explicit type casts when size_t is converted to int On line 345 we must check that `str->d` is not NULL because MSVC code analyzer can't prove that `str->d` is not NULL when webvtt_create_string succeeds. `str->d` is assigned to `d` on line 348 and then `d` is dereferenced on line 364. Checking `str->d` against NULL helps the analyzer to understand that there is no NULL pointer derefernce on line 364.
- Calling fstream::close is not noexcept. Wrapping it in try-catch block helps static code analyzer to understand that destructor will not throw. - Replaced c-style cast with static_cast. - C++ core guidelines recommend to initialize local variables. Moving reading cycle and buffer into immediately invoked lambda expression reduces number of variables in outer scope and allows to initialize `status` and `finishStatus`.
C++ code should use C++-style casts or list initialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
*Issue #4
*Issue #6
Description of changes:
I checked compilation and ran tests under MSVC 2015, 2017, 2019, 2022 and gcc 9.4.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.