Bug 586731 jsd_NewSourceText leaks new_url_string ifndef LIVEWIRE

r=biesi
This commit is contained in:
timeless@mozdev.org 2011-03-28 16:49:16 -04:00
Родитель 7ad87fbc8e
Коммит 2968149819
3 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -590,7 +590,7 @@ jsd_AddFullSourceText(JSDContext* jsdc,
extern void extern void
jsd_DestroyAllSources(JSDContext* jsdc); jsd_DestroyAllSources(JSDContext* jsdc);
extern const char* extern char*
jsd_BuildNormalizedURL(const char* url_string); jsd_BuildNormalizedURL(const char* url_string);
extern void extern void

Просмотреть файл

@ -111,13 +111,13 @@ _appendText(JSDContext* jsdc, JSDSourceText* jsdsrc,
} }
static JSDSourceText* static JSDSourceText*
_newSource(JSDContext* jsdc, const char* url) _newSource(JSDContext* jsdc, char* url)
{ {
JSDSourceText* jsdsrc = (JSDSourceText*)calloc(1,sizeof(JSDSourceText)); JSDSourceText* jsdsrc = (JSDSourceText*)calloc(1,sizeof(JSDSourceText));
if( ! jsdsrc ) if( ! jsdsrc )
return NULL; return NULL;
jsdsrc->url = (char*) url; /* already a copy */ jsdsrc->url = url;
jsdsrc->status = JSD_SOURCE_INITED; jsdsrc->status = JSD_SOURCE_INITED;
jsdsrc->dirty = JS_TRUE; jsdsrc->dirty = JS_TRUE;
jsdsrc->alterCount = jsdc->sourceAlterCount++ ; jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
@ -142,7 +142,7 @@ _removeSource(JSDContext* jsdc, JSDSourceText* jsdsrc)
} }
static JSDSourceText* static JSDSourceText*
_addSource(JSDContext* jsdc, const char* url) _addSource(JSDContext* jsdc, char* url)
{ {
JSDSourceText* jsdsrc = _newSource(jsdc, url); JSDSourceText* jsdsrc = _newSource(jsdc, url);
if( ! jsdsrc ) if( ! jsdsrc )
@ -213,7 +213,7 @@ strncasecomp (const char* one, const char * two, int n)
static char file_url_prefix[] = "file:"; static char file_url_prefix[] = "file:";
#define FILE_URL_PREFIX_LEN (sizeof file_url_prefix - 1) #define FILE_URL_PREFIX_LEN (sizeof file_url_prefix - 1)
const char* char*
jsd_BuildNormalizedURL( const char* url_string ) jsd_BuildNormalizedURL( const char* url_string )
{ {
char *new_url_string; char *new_url_string;
@ -378,7 +378,7 @@ JSDSourceText*
jsd_NewSourceText(JSDContext* jsdc, const char* url) jsd_NewSourceText(JSDContext* jsdc, const char* url)
{ {
JSDSourceText* jsdsrc; JSDSourceText* jsdsrc;
const char* new_url_string; char* new_url_string;
JSD_LOCK_SOURCE_TEXT(jsdc); JSD_LOCK_SOURCE_TEXT(jsdc);
@ -396,9 +396,7 @@ jsd_NewSourceText(JSDContext* jsdc, const char* url)
{ {
if( jsdsrc->doingEval ) if( jsdsrc->doingEval )
{ {
#ifdef LIVEWIRE free(new_url_string);
free((char*)new_url_string);
#endif
JSD_UNLOCK_SOURCE_TEXT(jsdc); JSD_UNLOCK_SOURCE_TEXT(jsdc);
return NULL; return NULL;
} }

Просмотреть файл

@ -663,6 +663,8 @@ JSD_DestroyAllSources( JSDContext* jsdc );
* Add a new item for a given URL. If an iten already exists for the given URL * Add a new item for a given URL. If an iten already exists for the given URL
* then the old item is removed. * then the old item is removed.
* 'url' may not be NULL. * 'url' may not be NULL.
*
* ifdef LIVEWIRE url is treated as a char* and ownership is claimed by jsd
*/ */
extern JSD_PUBLIC_API(JSDSourceText*) extern JSD_PUBLIC_API(JSDSourceText*)
JSD_NewSourceText(JSDContext* jsdc, const char* url); JSD_NewSourceText(JSDContext* jsdc, const char* url);