mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
heh, slight oversight when implementing rcall using the param pointer
trick. ran into the exact same problem as passing addresses of locals to QC functions. well, actually, that's exactly what it was, but done in the engine. anyway, wound up potentially overwriting the params passed to the function. fortunatly, due to how rcall works, only the first two params are an issue.
This commit is contained in:
parent
2cc2da74ba
commit
4a21eb02c5
1 changed files with 31 additions and 0 deletions
|
@ -125,9 +125,40 @@ PR_EnterFunction (progs_t *pr, dfunction_t *f)
|
|||
{
|
||||
int i, j, c, o;
|
||||
int k;
|
||||
int count = 0;
|
||||
int size[2] = {0, 0};
|
||||
long paramofs = 0;
|
||||
long offs;
|
||||
|
||||
PR_PushFrame (pr);
|
||||
|
||||
if (f->numparms > 0) {
|
||||
for (i = 0; i < 2 && i < f->numparms; i++) {
|
||||
paramofs += f->parm_size[i];
|
||||
size[i] = f->parm_size[i];
|
||||
}
|
||||
count = i;
|
||||
} else if (f->numparms < 0) {
|
||||
for (i = 0; i < 2 && i < -f->numparms - 1; i++) {
|
||||
paramofs += f->parm_size[i];
|
||||
size[i] = f->parm_size[i];
|
||||
}
|
||||
for (; i < 2; i++) {
|
||||
paramofs += pr->pr_param_size;
|
||||
size[i] = pr->pr_param_size;
|
||||
}
|
||||
count = i;
|
||||
}
|
||||
|
||||
for (i = 0; i < count && i < pr->pr_argc; i++) {
|
||||
offs = (pr->pr_params[i] - pr->pr_globals) - f->parm_start;
|
||||
if (offs >= 0 && offs < paramofs) {
|
||||
memcpy (pr->pr_real_params[i], pr->pr_params[i],
|
||||
size[i] * sizeof (pr_type_t));
|
||||
pr->pr_params[i] = pr->pr_real_params[i];
|
||||
}
|
||||
}
|
||||
|
||||
//Sys_Printf("%s:\n", PR_GetString(pr,f->s_name));
|
||||
pr->pr_xfunction = f;
|
||||
pr->pr_xstatement = f->first_statement - 1; // offset the st++
|
||||
|
|
Loading…
Reference in a new issue