mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41: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 <cassert>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
|
||||
@ -255,6 +256,8 @@ Packet& Packet::operator>>(double& data)
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& Packet::operator>>(char* data)
|
||||
{
|
||||
assert(data && "Packet::operator>> Data must not be null");
|
||||
|
||||
// First extract string length
|
||||
std::uint32_t length = 0;
|
||||
*this >> length;
|
||||
@ -297,6 +300,8 @@ Packet& Packet::operator>>(std::string& data)
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& Packet::operator>>(wchar_t* data)
|
||||
{
|
||||
assert(data && "Packet::operator>> Data must not be null");
|
||||
|
||||
// First extract string length
|
||||
std::uint32_t length = 0;
|
||||
*this >> length;
|
||||
@ -482,6 +487,8 @@ Packet& Packet::operator<<(double data)
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& Packet::operator<<(const char* data)
|
||||
{
|
||||
assert(data && "Packet::operator<< Data must not be null");
|
||||
|
||||
// First insert string length
|
||||
const auto length = static_cast<std::uint32_t>(std::strlen(data));
|
||||
*this << length;
|
||||
@ -511,6 +518,8 @@ Packet& Packet::operator<<(const std::string& data)
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& Packet::operator<<(const wchar_t* data)
|
||||
{
|
||||
assert(data && "Packet::operator<< Data must not be null");
|
||||
|
||||
// First insert string length
|
||||
const auto length = static_cast<std::uint32_t>(std::wcslen(data));
|
||||
*this << length;
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <ostream>
|
||||
#include <utility>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -135,6 +137,7 @@ bool Context::isExtensionAvailable(std::string_view name)
|
||||
////////////////////////////////////////////////////////////
|
||||
GlFunctionPointer Context::getFunction(const char* name)
|
||||
{
|
||||
assert(name && "Context::getFunction Name must not be null");
|
||||
return priv::GlContext::getFunction(name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user