summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/xslt/sablot.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/xslt/sablot.c b/ext/xslt/sablot.c
index 4012b4050d..26af287734 100644
--- a/ext/xslt/sablot.c
+++ b/ext/xslt/sablot.c
@@ -1435,7 +1435,7 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M
char *ptr; /* Pointer to the location of the ':' (separator) */
int pos; /* Position of the ':' (separator) */
int len; /* Length of the string */
-
+
len = strlen(*fields);
/* Grab the separator's position */
@@ -1507,8 +1507,8 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M
key = emalloc(pos + 1);
val = emalloc((len - pos) + 1);
- strlcpy(key, *fields, pos);
- strlcpy(val, *fields + pos + 1, len - pos - 1);
+ strlcpy(key, *fields, pos + 1);
+ strlcpy(val, *fields + pos + 1, len - pos);
/* Check to see whether or not we want to save the data */
if (!strcmp(key, "msg")) {
@@ -1517,7 +1517,7 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M
else if (!strcmp(key, "line")) {
errline = estrdup(val);
}
-
+
/* Cleanup */
if (key) efree(key);
if (val) efree(val);
@@ -1531,6 +1531,10 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M
errline = estrndup("none", sizeof("none") - 1);
}
+ if (!errmsg) {
+ errmsg = estrndup("unkown error", sizeof("unkown error") - 1);
+ }
+
/* Allocate the message buffer and copy the data onto it */
msgbuf = emalloc((sizeof(msgformat) - 4) + strlen(errmsg) + strlen(errline) + 1);
sprintf(msgbuf, msgformat, errline, errmsg);