p = myself->progname;
WCHAR corefile[wcslen (p) + sizeof (".stackdump")];
- wcscpy(corefile, p);
+ wcpcpy (wcpcpy(corefile, p), L".stackdump");
UNICODE_STRING ucore;
OBJECT_ATTRIBUTES attr;
/* Create the UNICODE variation of <progname>.stackdump. */
RtlInitUnicodeString (&ucore, corefile);
- RtlAppendUnicodeToString (&ucore, L".stackdump");
/* Create an object attribute which refers to <progname>.stackdump
in Cygwin's cwd. Stick to caseinsensitivity. */
InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE,
arrays. What we do here is just treat the lc_foo pointers as char ** and
rebase all char * pointers within, up to the given size of the structure. */
static void
-rebase_locale_buf (const void *ptrv, const char *newbase, const char *oldbase,
- const void *ptrvend)
+rebase_locale_buf (const void *ptrv, const void *ptrvend, const char *newbase,
+ const char *oldbase, const char *oldend)
{
- const char **ptrs = (const char **) ptrv;
const char **ptrsend = (const char **) ptrvend;
- while (ptrs < ptrsend)
- *ptrs++ += newbase - oldbase;
+ for (const char **ptrs = (const char **) ptrv; ptrs < ptrsend; ++ptrs)
+ if (*ptrs >= oldbase && *ptrs < oldend)
+ *ptrs += newbase - oldbase;
}
static wchar_t *
else
{
if (tmp != new_lc_time_buf)
- rebase_locale_buf (_time_locale, tmp, new_lc_time_buf,
- _time_locale + 1);
+ rebase_locale_buf (_time_locale, _time_locale + 1, tmp,
+ new_lc_time_buf, lc_time_ptr);
lc_time_ptr = tmp + (lc_time_ptr - new_lc_time_buf);
new_lc_time_buf = tmp;
lc_time_end = new_lc_time_buf + len;
return -1;
}
if (tmp != new_lc_time_buf)
- rebase_locale_buf (_time_locale, tmp, new_lc_time_buf,
- _time_locale + 1);
+ rebase_locale_buf (_time_locale, _time_locale + 1, tmp,
+ new_lc_time_buf, lc_time_ptr);
if (*lc_time_buf)
free (*lc_time_buf);
*lc_time_buf = tmp;
return -1;
}
if (tmp != new_lc_ctype_buf)
- rebase_locale_buf (_ctype_locale, tmp, new_lc_ctype_buf,
- _ctype_locale + 1);
+ rebase_locale_buf (_ctype_locale, _ctype_locale + 1, tmp,
+ new_lc_ctype_buf, lc_ctype_ptr);
if (*lc_ctype_buf)
free (*lc_ctype_buf);
*lc_ctype_buf = tmp;
return -1;
}
if (tmp != new_lc_numeric_buf)
- rebase_locale_buf (_numeric_locale, tmp, new_lc_numeric_buf,
- _numeric_locale + 1);
+ rebase_locale_buf (_numeric_locale, _numeric_locale + 1, tmp,
+ new_lc_numeric_buf, lc_numeric_ptr);
if (*lc_numeric_buf)
free (*lc_numeric_buf);
*lc_numeric_buf = tmp;
return -1;
}
if (tmp != new_lc_monetary_buf)
- rebase_locale_buf (_monetary_locale, tmp, new_lc_monetary_buf,
- _monetary_locale + 1);
+ rebase_locale_buf (_monetary_locale, _monetary_locale + 1, tmp,
+ new_lc_monetary_buf, lc_monetary_ptr);
if (*lc_monetary_buf)
free (*lc_monetary_buf);
*lc_monetary_buf = tmp;