Commit 8ff0cd04 authored by Justus Piater's avatar Justus Piater Committed by Rémi Denis-Courmont

consistently use malloc()/free() for C-style strings

There was a mix of new/delete, malloc()/free() and even several
malloc()/delete, so this fixes actual bugs.
Signed-off-by: default avatarRémi Denis-Courmont <rdenis@simphalempin.com>
parent 9e406ba7
......@@ -1423,7 +1423,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
{
url = p_plugin->getAbsoluteURL(s);
if( url )
delete s;
free(s);
else
// problem with combining url, use argument
url = s;
......@@ -1449,7 +1449,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
else
{
delete url;
free(url);
return INVOKERESULT_INVALID_VALUE;
}
}
......@@ -1475,8 +1475,8 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
else
{
delete url;
delete name;
free(url);
free(name);
return INVOKERESULT_INVALID_VALUE;
}
}
......@@ -1487,13 +1487,13 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
i_options,
const_cast<const char **>(ppsz_options),
&ex);
delete url;
delete name;
free(url);
free(name);
for( int i=0; i< i_options; ++i )
{
delete ppsz_options[i];
free(ppsz_options[i]);
}
delete ppsz_options;
free(ppsz_options);
if( libvlc_exception_raised(&ex) )
{
......@@ -1695,7 +1695,7 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &nps, int *i_options, c
if( ! moreOptions )
{
/* failed to allocate more memory */
delete s;
free(s);
/* return what we got so far */
*i_options = nOptions;
*ppsz_options = options;
......@@ -1713,7 +1713,7 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &nps, int *i_options, c
*i_options = nOptions;
*ppsz_options = options;
}
delete s;
free(s);
}
}
}
......@@ -1985,7 +1985,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
}
libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
delete psz_aspect;
free(psz_aspect);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) )
......@@ -2032,7 +2032,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
}
libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
delete psz_geometry;
free(psz_geometry);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) )
......
......@@ -37,7 +37,7 @@
char* RuntimeNPObject::stringValue(const NPString &s)
{
NPUTF8 *val = new NPUTF8[s.utf8length+1];
NPUTF8 *val = static_cast<NPUTF8*>(malloc((s.utf8length+1) * sizeof(*val)));
if( val )
{
strncpy(val, s.utf8characters, s.utf8length);
......
......@@ -82,7 +82,7 @@ static bool boolValue(const char *value) {
NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{
/* prepare VLC command line */
char *ppsz_argv[32];
const char *ppsz_argv[32];
int ppsz_argc = 0;
/* locate VLC module path */
......@@ -218,7 +218,7 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{
NPString &location = NPVARIANT_TO_STRING(result);
psz_baseURL = new char[location.utf8length+1];
psz_baseURL = static_cast<char*>(malloc(location.utf8length+1));
if( psz_baseURL )
{
strncpy(psz_baseURL, location.utf8characters, location.utf8length);
......@@ -246,8 +246,8 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
VlcPlugin::~VlcPlugin()
{
delete[] psz_baseURL;
delete psz_target;
free(psz_baseURL);
free(psz_target);
if( libvlc_log )
libvlc_log_close(libvlc_log, NULL);
if( libvlc_instance )
......@@ -295,7 +295,7 @@ relativeurl:
if( psz_baseURL )
{
size_t baseLen = strlen(psz_baseURL);
char *href = new char[baseLen+strlen(url)+1];
char *href = static_cast<char*>(malloc(baseLen+strlen(url)+1));
if( href )
{
/* prepend base URL */
......@@ -340,7 +340,7 @@ relativeurl:
if( '/' != *href )
{
/* baseURL is not an absolute path */
delete[] href;
free(href);
return NULL;
}
pathstart = href;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment