Jacek Caban : jscript: Pass msg as jsstr_t to create_error.
Alexandre Julliard
julliard at winehq.org
Fri Mar 8 14:00:37 CST 2013
Module: wine
Branch: master
Commit: c7c71b87b894bb67d8b9a136162a66a273bedf61
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c7c71b87b894bb67d8b9a136162a66a273bedf61
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Mar 8 11:37:30 2013 +0100
jscript: Pass msg as jsstr_t to create_error.
---
dlls/jscript/error.c | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c
index 3e15144..41cba5a 100644
--- a/dlls/jscript/error.c
+++ b/dlls/jscript/error.c
@@ -180,10 +180,9 @@ static HRESULT alloc_error(script_ctx_t *ctx, jsdisp_t *prototype,
}
static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
- UINT number, const WCHAR *msg, jsdisp_t **ret)
+ UINT number, jsstr_t *msg, jsdisp_t **ret)
{
jsdisp_t *err;
- jsstr_t *str;
HRESULT hres;
hres = alloc_error(ctx, NULL, constr, &err);
@@ -196,16 +195,9 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
return hres;
}
- if(msg) str = jsstr_alloc(msg);
- else str = jsstr_empty();
- if(str) {
- hres = jsdisp_propput_name(err, messageW, jsval_string(str));
- if(SUCCEEDED(hres))
- hres = jsdisp_propput_dontenum(err, descriptionW, jsval_string(str));
- jsstr_release(str);
- }else {
- hres = E_OUTOFMEMORY;
- }
+ hres = jsdisp_propput_name(err, messageW, jsval_string(msg));
+ if(SUCCEEDED(hres))
+ hres = jsdisp_propput_dontenum(err, descriptionW, jsval_string(msg));
if(FAILED(hres)) {
jsdisp_release(err);
return hres;
@@ -235,19 +227,21 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_
num = n;
}
- if(argc>1 && !msg) {
- hres = to_string(ctx, argv[1], &msg);
- if(FAILED(hres))
- return hres;
+ if(!msg) {
+ if(argc > 1) {
+ hres = to_string(ctx, argv[1], &msg);
+ if(FAILED(hres))
+ return hres;
+ }else {
+ msg = jsstr_empty();
+ }
}
switch(flags) {
case INVOKE_FUNC:
case DISPATCH_CONSTRUCT:
- hres = create_error(ctx, constr, num, msg ? msg->str : NULL, &err);
- if(msg)
- jsstr_release(msg);
-
+ hres = create_error(ctx, constr, num, msg, &err);
+ jsstr_release(msg);
if(FAILED(hres))
return hres;
@@ -375,6 +369,7 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j
{
WCHAR buf[1024], *pos = NULL;
jsdisp_t *err;
+ jsstr_t *msg;
HRESULT hres;
if(!is_jscript_error(error))
@@ -392,7 +387,12 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j
WARN("%s\n", debugstr_w(buf));
- hres = create_error(ctx, constr, error, buf, &err);
+ msg = jsstr_alloc(buf);
+ if(!msg)
+ return E_OUTOFMEMORY;
+
+ hres = create_error(ctx, constr, error, msg, &err);
+ jsstr_release(msg);
if(FAILED(hres))
return hres;
More information about the wine-cvs
mailing list