[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[mgp-users-jp 01339] NULL check of (o|s)image->title in argument of sprintf()
- To: mgp-users-jp@mew.org
- Subject: [mgp-users-jp 01339] NULL check of (o|s)image->title in argument of sprintf()
- From: Ryo HAYASAKA <ryoh@jaist.ac.jp>
- Date: Sat, 23 Aug 2003 00:12:00 +0900 (JST)
- Delivered-to: mailing list mgp-users-jp@mew.org
- Mailing-list: contact mgp-users-jp-help@mew.org; run by ezmlm
早坂といいます.
Solaris8 で, 下のパッチの sprintf() の引数の (s|o)title が NULL の場合に,
mgp が core を吐いてしまいます. NULL かどうかのチェックをその前に加えて
あげれば良いような気がしますが, いかがでしょう?
# 余談. ちなみに, NetBSD ですと
printf("%s", NULL);
が
(null)
という文字列になるので落ちませんね.
Index: image/rotate.c
===================================================================
RCS file: /cvsmgp/kit/image/rotate.c,v
retrieving revision 1.4
diff -d -p -u -r1.4 rotate.c
--- image/rotate.c 1998/12/28 08:23:22 1.4
+++ image/rotate.c 2003/08/11 17:24:25
@@ -69,7 +69,8 @@ int degrees; /* Number of degrees
{ fprintf(stderr, " Rotating image by %d degrees...", degrees);
fflush(stderr);
}
- sprintf(buf, "%s (rotated by %d degrees)", simage->title, degrees);
+ if (simage->title)
+ sprintf(buf, "%s (rotated by %d degrees)", simage->title, degrees);
image1 = simage;
do {
Index: image/zoom.c
===================================================================
RCS file: /cvsmgp/kit/image/zoom.c,v
retrieving revision 1.4
diff -d -p -u -r1.4 zoom.c
--- image/zoom.c 1999/11/28 14:35:16 1.4
+++ image/zoom.c 2003/08/11 17:24:25
@@ -60,24 +60,28 @@ Image *zoom(oimage, xzoom, yzoom, verbos
if (xzoom == 0.0) {
if (verbose)
fprintf(stderr, " Zooming image Y axis by %0.2f%%...", yzoom);
+ if (oimage->title)
sprintf(buf, "%s (Y zoom %0.2f%%)", oimage->title, yzoom);
}
else if (yzoom == 0.0) {
if (verbose)
fprintf(stderr, " Zooming image X axis by %0.2f%%...", xzoom);
- sprintf(buf, "%s (X zoom %0.2f%%)", oimage->title, xzoom);
+ if (oimage->title)
+ sprintf(buf, "%s (X zoom %0.2f%%)", oimage->title, xzoom);
}
else if (xzoom == yzoom) {
if (verbose)
fprintf(stderr, " Zooming image by %0.2f%%...", xzoom);
- sprintf(buf, "%s (%d%% zoom)", oimage->title, xzoom);
+ if (oimage->title)
+ sprintf(buf, "%s (%d%% zoom)", oimage->title, xzoom);
}
else {
if (verbose)
fprintf(stderr, " Zooming image X axis by %0.2f%% and Y axis by %0.2f%%...",
xzoom, yzoom);
- sprintf(buf, "%s (X zoom %0.2f%% Y zoom %0.2f%%)", oimage->title,
- xzoom, yzoom);
+ if (oimage->title)
+ sprintf(buf, "%s (X zoom %0.2f%% Y zoom %0.2f%%)", oimage->title,
+ xzoom, yzoom);
}
if (verbose)
fflush(stderr);
--
Ryo HAYASAKA (早坂 良) <ryoh@jaist.ac.jp>