mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Assert against C-style string arguments being null
This commit is contained in:
parent
74dfd76b25
commit
61d78105e3
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
|
|
||||||
@ -255,6 +256,8 @@ Packet& Packet::operator>>(double& data)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Packet& Packet::operator>>(char* data)
|
Packet& Packet::operator>>(char* data)
|
||||||
{
|
{
|
||||||
|
assert(data && "Packet::operator>> Data must not be null");
|
||||||
|
|
||||||
// First extract string length
|
// First extract string length
|
||||||
std::uint32_t length = 0;
|
std::uint32_t length = 0;
|
||||||
*this >> length;
|
*this >> length;
|
||||||
@ -297,6 +300,8 @@ Packet& Packet::operator>>(std::string& data)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Packet& Packet::operator>>(wchar_t* data)
|
Packet& Packet::operator>>(wchar_t* data)
|
||||||
{
|
{
|
||||||
|
assert(data && "Packet::operator>> Data must not be null");
|
||||||
|
|
||||||
// First extract string length
|
// First extract string length
|
||||||
std::uint32_t length = 0;
|
std::uint32_t length = 0;
|
||||||
*this >> length;
|
*this >> length;
|
||||||
@ -482,6 +487,8 @@ Packet& Packet::operator<<(double data)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Packet& Packet::operator<<(const char* data)
|
Packet& Packet::operator<<(const char* data)
|
||||||
{
|
{
|
||||||
|
assert(data && "Packet::operator<< Data must not be null");
|
||||||
|
|
||||||
// First insert string length
|
// First insert string length
|
||||||
const auto length = static_cast<std::uint32_t>(std::strlen(data));
|
const auto length = static_cast<std::uint32_t>(std::strlen(data));
|
||||||
*this << length;
|
*this << length;
|
||||||
@ -511,6 +518,8 @@ Packet& Packet::operator<<(const std::string& data)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Packet& Packet::operator<<(const wchar_t* data)
|
Packet& Packet::operator<<(const wchar_t* data)
|
||||||
{
|
{
|
||||||
|
assert(data && "Packet::operator<< Data must not be null");
|
||||||
|
|
||||||
// First insert string length
|
// First insert string length
|
||||||
const auto length = static_cast<std::uint32_t>(std::wcslen(data));
|
const auto length = static_cast<std::uint32_t>(std::wcslen(data));
|
||||||
*this << length;
|
*this << length;
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -135,6 +137,7 @@ bool Context::isExtensionAvailable(std::string_view name)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlFunctionPointer Context::getFunction(const char* name)
|
GlFunctionPointer Context::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
|
assert(name && "Context::getFunction Name must not be null");
|
||||||
return priv::GlContext::getFunction(name);
|
return priv::GlContext::getFunction(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user