From: <ny...@us...> - 2006-07-10 19:15:31
|
Revision: 129 Author: nyaochi Date: 2006-07-10 12:15:25 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=129&view=rev Log Message: ----------- Fix for NULL error messages. Modified Paths: -------------- trunk/lib/playlist/jspl.c Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-07-10 18:32:34 UTC (rev 128) +++ trunk/lib/playlist/jspl.c 2006-07-10 19:15:25 UTC (rev 129) @@ -37,6 +37,7 @@ #include <pmp.h> #include <playlist.h> +#define JS_THREADSAFE #include <jsapi.h> #define MAX_SOURCE_DEPTH 64 @@ -92,15 +93,17 @@ static void error_handler(JSContext *cx, const char *message, JSErrorReport *report) { + ucs2char_t* ucs2 = NULL; jspl_t* jspl = (jspl_t*)JS_GetContextPrivate(cx); - ucs2char_t* ucs2 = NULL; - char *pos = alloca(strlen(report->filename) + 64); /* extra 64 bytes for line numbers. */ + const char *msg = message ? message : "Unknown error"; + const char *filename = report->filename ? report->filename : "(Unknown filename)"; + char *pos = alloca(strlen(filename) + 64); /* extra 64 bytes for line numbers. */ - ucs2 = mbsdupucs2(message); + ucs2 = mbsdupucs2(msg); jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR, ucs2); ucs2free(ucs2); - sprintf(pos, "lines %d in %s", report->lineno, report->filename); + sprintf(pos, "lines %d in %s", report->lineno, filename); ucs2 = mbsdupucs2(pos); jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_POS, ucs2); ucs2free(ucs2); @@ -608,10 +611,10 @@ } /* Check if main() function exists. */ - if (!function_exists(jspl, "main")) { + /*if (!function_exists(jspl, "main")) { ret = PLAYLIST_E_JSMAINNOTFOUND; goto error_exit; - } + }*/ /* Call main() function. */ argv[0] = OBJECT_TO_JSVAL(jspl->tracks); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |