mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
(string_replace_substring) Add early return if 'in' is NULL
This commit is contained in:
parent
e4cfbcf93a
commit
a6fc76ac87
@ -24,14 +24,18 @@
|
|||||||
|
|
||||||
char *string_replace_substring(const char *in, const char *pattern, const char *by)
|
char *string_replace_substring(const char *in, const char *pattern, const char *by)
|
||||||
{
|
{
|
||||||
char *needle;
|
char *needle = NULL, *res = NULL;
|
||||||
size_t outsize = strlen(in) + 1;
|
size_t outsize = 0;
|
||||||
/* use this to iterate over the output */
|
|
||||||
size_t resoffset = 0;
|
size_t resoffset = 0;
|
||||||
|
|
||||||
|
if (!in)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
outsize = strlen(in) + 1;
|
||||||
|
|
||||||
/* TODO maybe avoid reallocating by counting the
|
/* TODO maybe avoid reallocating by counting the
|
||||||
* non-overlapping occurences of pattern */
|
* non-overlapping occurences of pattern */
|
||||||
char *res = malloc(outsize);
|
res = (char*)malloc(outsize);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user