From 55f68c36574779ae2fac3652466584628b22c633 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 16:54:24 +0000 Subject: fix for more warnings. - modifier code was using sizeof() without knowing the sizeof the array when clearing the modifier type array. - use BLI_snprintf rather then sprintf where the size of the string is known. - particle drawing code kept a reference to stack float values (not a problem at the moment but would crash if accessed later). --- source/blender/imbuf/intern/thumbs.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 8abc2e89952..16411ec3549 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -202,7 +202,7 @@ static int uri_from_filename( const char *path, char *uri ) return 1; } -static void thumbname_from_uri(const char* uri, char* thumb) +static void thumbname_from_uri(const char* uri, char* thumb, const int thumb_len) { char hexdigest[33]; unsigned char digest[16]; @@ -211,18 +211,18 @@ static void thumbname_from_uri(const char* uri, char* thumb) hexdigest[0] = '\0'; to_hex_char(hexdigest, digest, 16); hexdigest[32] = '\0'; - sprintf(thumb, "%s.png", hexdigest); + BLI_snprintf(thumb, thumb_len, "%s.png", hexdigest); } -static int thumbpath_from_uri(const char* uri, char* path, ThumbSize size) +static int thumbpath_from_uri(const char* uri, char* path, const int path_len, ThumbSize size) { char tmppath[FILE_MAX]; int rv = 0; if (get_thumb_dir(tmppath, size)) { char thumb[40]; - thumbname_from_uri(uri, thumb); - BLI_snprintf(path, FILE_MAX, "%s%s", tmppath, thumb); + thumbname_from_uri(uri, thumb, sizeof(thumb)); + BLI_snprintf(path, path_len, "%s%s", tmppath, thumb); rv = 1; } return rv; @@ -271,7 +271,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im } uri_from_filename(path, uri); - thumbname_from_uri(uri, thumb); + thumbname_from_uri(uri, thumb, sizeof(thumb)); if (get_thumb_dir(tdir, size)) { BLI_snprintf(tpath, FILE_MAX, "%s%s", tdir, thumb); thumb[8] = '\0'; /* shorten for tempname, not needed anymore */ @@ -297,9 +297,9 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im if (img != NULL) { stat(path, &info); - sprintf(mtime, "%ld", info.st_mtime); - sprintf(cwidth, "%d", img->x); - sprintf(cheight, "%d", img->y); + BLI_snprintf(mtime, sizeof(mtime), "%ld", info.st_mtime); + BLI_snprintf(cwidth, sizeof(cwidth), "%d", img->x); + BLI_snprintf(cheight, sizeof(cheight), "%d", img->y); } } else if (THB_SOURCE_MOVIE == source) { struct anim * anim = NULL; @@ -315,7 +315,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im IMB_free_anim(anim); } stat(path, &info); - sprintf(mtime, "%ld", info.st_mtime); + BLI_snprintf(mtime, sizeof(mtime), "%ld", info.st_mtime); } if (!img) return 0; @@ -332,7 +332,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im IMB_scaleImBuf(img, ex, ey); } - sprintf(desc, "Thumbnail for %s", uri); + BLI_snprintf(desc, sizeof(desc), "Thumbnail for %s", uri); IMB_metadata_change_field(img, "Description", desc); IMB_metadata_change_field(img, "Software", "Blender"); IMB_metadata_change_field(img, "Thumb::URI", uri); @@ -365,7 +365,7 @@ ImBuf* IMB_thumb_read(const char* path, ThumbSize size) if (!uri_from_filename(path,uri)) { return NULL; } - if (thumbpath_from_uri(uri, thumb, size)) { + if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { img = IMB_loadiffname(thumb, IB_rect | IB_metadata); } @@ -381,7 +381,7 @@ void IMB_thumb_delete(const char* path, ThumbSize size) if (!uri_from_filename(path ,uri)) { return; } - if (thumbpath_from_uri(uri, thumb, size)) { + if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { if (strncmp(path, thumb, strlen(thumb)) == 0) { return; } @@ -406,14 +406,14 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) if (!uri_from_filename(path,uri)) { return NULL; } - if (thumbpath_from_uri(uri, thumb, THB_FAIL)) { + if (thumbpath_from_uri(uri, thumb, sizeof(thumb), THB_FAIL)) { /* failure thumb exists, don't try recreating */ if (BLI_exists(thumb)) { return NULL; } } - if (thumbpath_from_uri(uri, thumb, size)) { + if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { if (strncmp(path, thumb, strlen(thumb)) == 0) { img = IMB_loadiffname(path, IB_rect); } else { -- cgit v1.2.3