X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fdata-out.c;h=53d9850db88a0da0ffb9ac3c1a76ada0d097955b;hb=18f6e8958244f938e9e9a03a4230cacf0d22a470;hp=78668b7aed96685b52b6934f277239e36dd92dab;hpb=77e551d23575da6b89f866612ab39c2b0497c9be;p=pspp diff --git a/src/data/data-out.c b/src/data/data-out.c index 78668b7aed..53d9850db8 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -395,7 +395,7 @@ convert_Z (char *dst, const struct fmt_spec *fp, double number) static int convert_A (char *dst, const struct fmt_spec *fp, const char *string) { - memcpy (dst, string, fp->w); + memcpy(dst, string, fp->w); return 1; } @@ -1063,6 +1063,7 @@ try_F (char *dst, const struct fmt_spec *fp, double number) avoids wasting too much time formatting more decimal places on the first try. */ int result = format_and_round (dst, number, fp, fp->d + 2); + if (result >= 0) return result; @@ -1143,7 +1144,7 @@ format_and_round (char *dst, double number, const struct fmt_spec *fp, digits of the fraction. Right-justify the integer part and sign. */ dst[0] = ' '; - memcpy (dst + 1, buf, fp->w); + memcpy (dst + 1, buf, fp->w - 1); return 1; }