projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix up potential overflows in size calculations by replacing
[pspp]
/
src
/
ascii.c
diff --git
a/src/ascii.c
b/src/ascii.c
index ae3c805b956a0b18981f56956aabc187ec49f107..bd55d0efee9b94905dde4dec4715d7c8065f07c5 100644
(file)
--- a/
src/ascii.c
+++ b/
src/ascii.c
@@
-195,7
+195,7
@@
static struct outp_option_info *option_info;
static int
ascii_open_global (struct outp_class *this UNUSED)
{
static int
ascii_open_global (struct outp_class *this UNUSED)
{
- option_info = xmalloc (
sizeof (struct outp_option_info ) )
;
+ option_info = xmalloc (
sizeof *option_info)
;
option_info->initial = 0;
option_info->options = 0;
return 1;
option_info->initial = 0;
option_info->options = 0;
return 1;
@@
-231,7
+231,7
@@
ascii_preopen_driver (struct outp_driver *this)
assert (this->driver_open == 0);
msg (VM (1), _("ASCII driver initializing as `%s'..."), this->name);
assert (this->driver_open == 0);
msg (VM (1), _("ASCII driver initializing as `%s'..."), this->name);
- this->ext = x = xmalloc (sizeof
(struct ascii_driver_ext)
);
+ this->ext = x = xmalloc (sizeof
*x
);
x->char_set = CHS_ASCII;
x->headers = 1;
x->page_length = 66;
x->char_set = CHS_ASCII;
x->headers = 1;
x->page_length = 66;
@@
-716,7
+716,7
@@
ascii_open_page (struct outp_driver *this)
if (x->l > x->lines_cap)
{
if (x->l > x->lines_cap)
{
- x->lines = x
realloc (x->lines, sizeof *x->lines * x->l
);
+ x->lines = x
nrealloc (x->lines, x->l, sizeof *x->lines
);
for (i = x->lines_cap; i < x->l; i++)
{
struct line *line = &x->lines[i];
for (i = x->lines_cap; i < x->l; i++)
{
struct line *line = &x->lines[i];
@@
-746,8
+746,8
@@
expand_line (struct ascii_driver_ext *x, int i, int l)
if (l > line->char_cap)
{
line->char_cap = l * 2;
if (l > line->char_cap)
{
line->char_cap = l * 2;
- line->chars = xrealloc (line->chars,
-
line->char_cap *
sizeof *line->chars);
+ line->chars = x
n
realloc (line->chars,
+
line->char_cap,
sizeof *line->chars);
}
for (j = line->char_cnt; j < l; j++)
line->chars[j] = ' ';
}
for (j = line->char_cnt; j < l; j++)
line->chars[j] = ' ';