Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix crash when enable heavy log and socket id less then 10. #2619

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

xiaozhihong
Copy link
Contributor

No description provided.

srtcore/core.cpp Outdated Show resolved Hide resolved
@ethouris ethouris added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Jan 18, 2023
@ethouris ethouris added this to the v1.5.2 milestone Jan 18, 2023
Copy link
Collaborator

@maxsharabayko maxsharabayko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid std::setw does not truncate a value.

The field width determines the minimum number of characters to be written in some output representations. If the standard width of the representation is shorter than the field width, the representation is padded with fill characters at a point determined by the format flag adjustfield (one of left, right or internal).

// setw example
#include <iostream>     // std::cout, std::endl
#include <iomanip>      // std::setw

int main () {
  std::cout << std::setfill('0') << std::setw(2) << 277 << std::endl;
  std::cout << std::setfill('0') << std::setw(2) << 2 << std::endl;
  return 0;
}

Output:

277
02

@ethouris
Copy link
Collaborator

The idea here is not to truncate value, but to ensure that the resulting string has at least 2 characters. That's why setw was required to ensure this, and then these last 2 ciphers from the resulting string should still be taken.

@maxsharabayko
Copy link
Collaborator

The idea here is not to truncate value, but to ensure that the resulting string has at least 2 characters. That's why setw was required to ensure this, and then these last 2 ciphers from the resulting string should still be taken.

Then s.substr(s.size()-2, 2); must remain.

@ethouris
Copy link
Collaborator

Exactly, that's what I meant.

srtcore/core.cpp Outdated Show resolved Hide resolved
@maxsharabayko maxsharabayko merged commit 6c92a13 into Haivision:master Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants