mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-02 06:38:04 +00:00
[Core] scan-build: fix false-positive memory leak in switch_xml_set_attr_d and switch_xml_set_attr_d_buf
This commit is contained in:
parent
781180ff48
commit
c35a3bb4db
@ -243,14 +243,6 @@ static inline void *switch_must_realloc(void *_b, size_t _z)
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *switch_must_strdup(const char *_s)
|
|
||||||
{
|
|
||||||
char *s = strdup(_s);
|
|
||||||
switch_assert(s);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\defgroup core1 Core Library
|
\defgroup core1 Core Library
|
||||||
\ingroup FREESWITCH
|
\ingroup FREESWITCH
|
||||||
|
@ -1487,6 +1487,8 @@ SWITCH_DECLARE(unsigned long) switch_getpid(void);
|
|||||||
SWITCH_DECLARE(switch_status_t) switch_digest(const char *digest_name, unsigned char **digest, const void *input, switch_size_t inputLen, unsigned int *outputlen);
|
SWITCH_DECLARE(switch_status_t) switch_digest(const char *digest_name, unsigned char **digest, const void *input, switch_size_t inputLen, unsigned int *outputlen);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_digest_string(const char *digest_name, char **digest_str, const void *input, switch_size_t inputLen, unsigned int *outputlen);
|
SWITCH_DECLARE(switch_status_t) switch_digest_string(const char *digest_name, char **digest_str, const void *input, switch_size_t inputLen, unsigned int *outputlen);
|
||||||
|
|
||||||
|
char *switch_must_strdup(const char *_s);
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
@ -4639,6 +4639,13 @@ SWITCH_DECLARE(switch_status_t) switch_digest_string(const char *digest_name, ch
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *switch_must_strdup(const char *_s)
|
||||||
|
{
|
||||||
|
char *s = strdup(_s);
|
||||||
|
switch_assert(s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* mode:c
|
* mode:c
|
||||||
|
@ -3040,7 +3040,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr(switch_xml_t xml, const char *n
|
|||||||
SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d(switch_xml_t xml, const char *name, const char *value)
|
SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d(switch_xml_t xml, const char *name, const char *value)
|
||||||
{
|
{
|
||||||
if (!xml) return NULL;
|
if (!xml) return NULL;
|
||||||
return switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)));
|
return switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), switch_must_strdup(name), switch_must_strdup(switch_str_nil(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sets the given tag attribute or adds a new attribute if not found. A value
|
/* Sets the given tag attribute or adds a new attribute if not found. A value
|
||||||
@ -3048,7 +3048,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d(switch_xml_t xml, const char
|
|||||||
SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d_buf(switch_xml_t xml, const char *name, const char *value)
|
SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr_d_buf(switch_xml_t xml, const char *name, const char *value)
|
||||||
{
|
{
|
||||||
if (!xml) return NULL;
|
if (!xml) return NULL;
|
||||||
return switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value));
|
return switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), switch_must_strdup(name), switch_must_strdup(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sets a flag for the given tag and returns the tag */
|
/* sets a flag for the given tag and returns the tag */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user