mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Check for nullptr return from malloc, calloc, and realloc. (#1023)
These are used in ntcore and cscore. Add inline null-checking versions to wpi/memory.h and use them throughout.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/TCPConnector.h>
|
||||
#include <wpi/memory.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Handle.h"
|
||||
@@ -574,7 +575,8 @@ void CS_SetHttpCameraUrls(CS_Source source, const char** urls, int count,
|
||||
|
||||
char** CS_GetHttpCameraUrls(CS_Source source, int* count, CS_Status* status) {
|
||||
auto urls = cs::GetHttpCameraUrls(source, status);
|
||||
char** out = static_cast<char**>(std::malloc(urls.size() * sizeof(char*)));
|
||||
char** out =
|
||||
static_cast<char**>(wpi::CheckedMalloc(urls.size() * sizeof(char*)));
|
||||
*count = urls.size();
|
||||
for (size_t i = 0; i < urls.size(); ++i) out[i] = cs::ConvertToC(urls[i]);
|
||||
return out;
|
||||
|
||||
Reference in New Issue
Block a user