kopia lustrzana https://gitlab.com/sane-project/backends
Return copied values in sane_get_parameters()
Until now the code has been changing the frontend supplied pointer to point to our internal data structure. There are two problems with this. It orphans the data previously associated with that pointer, which causes a memory leak. It also gives the frontend the ability to munge our internal data structure. The only downside to this change is the possibility that a frontend took the spec too literally and merely supplies a pointer but does not allocate storage space for the result. Technically, the spec is a bit vague on this point, because it does not specifically state who should allocate the structure, but I feel a reasonable programmer would guess that space allocation is a frontend obligation.merge-requests/1/head
rodzic
64caf38683
commit
4d38523bda
|
@ -8112,9 +8112,16 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters* params)
|
|||
}
|
||||
|
||||
if (params) {
|
||||
*params = s->params;
|
||||
/* add background raster lines */
|
||||
params->lines += s->val[OPT_BACKGROUND].w;
|
||||
s->params.lines += s->val[OPT_BACKGROUND].w;
|
||||
|
||||
/* copy structure members */
|
||||
params->format = s->params.format;
|
||||
params->last_frame = s->params.last_frame;
|
||||
params->bytes_per_line = s->params.bytes_per_line;
|
||||
params->pixels_per_line = s->params.pixels_per_line;
|
||||
params->lines = s->params.lines;
|
||||
params->depth = s->params.depth;
|
||||
}
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
|
|
Ładowanie…
Reference in New Issue