[Bf-blender-cvs] [5b833de] master: ImBuf: Assert when read/write gets relative paths

Campbell Barton noreply at git.blender.org
Wed Jun 17 08:10:32 CEST 2015


Commit: 5b833de521f26c6f4af2e852ccf420f3661fb02a
Author: Campbell Barton
Date:   Wed Jun 17 15:53:35 2015 +1000
Branches: master
https://developer.blender.org/rB5b833de521f26c6f4af2e852ccf420f3661fb02a

ImBuf: Assert when read/write gets relative paths

We _never_ want this, so better not fail silently.

===================================================================

M	source/blender/imbuf/intern/anim_movie.c
M	source/blender/imbuf/intern/readimage.c
M	source/blender/imbuf/intern/util.c
M	source/blender/imbuf/intern/writeimage.c

===================================================================

diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 185dadc..2c8431d 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -271,6 +271,8 @@ struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char
 {
 	struct anim *anim;
 
+	BLI_assert(!BLI_path_is_rel(name));
+
 	anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct");
 	if (anim != NULL) {
 		if (colorspace) {
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 3cf123f..38d54e6 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -209,6 +209,8 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
 	int file, a;
 	char filepath_tx[IB_FILENAME_SIZE];
 
+	BLI_assert(!BLI_path_is_rel(filepath));
+
 	imb_cache_filename(filepath_tx, filepath, flags);
 
 	file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
@@ -237,6 +239,8 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
 	char filepath_tx[IB_FILENAME_SIZE];
 	char colorspace[IM_MAX_SPACE] = "\0";
 
+	BLI_assert(!BLI_path_is_rel(filepath));
+
 	imb_cache_filename(filepath_tx, filepath, flags);
 
 	file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 77962d4..8b16e03 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -190,7 +190,9 @@ int IMB_ispic_type(const char *name)
 	BLI_stat_t st;
 	int fp;
 
-	if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
+	BLI_assert(!BLI_path_is_rel(name));
+
+	if (UTIL_DEBUG) printf("%s: loading %s\n", __func__, name);
 	
 	if (BLI_stat(name, &st) == -1)
 		return false;
@@ -389,7 +391,9 @@ int imb_get_anim_type(const char *name)
 	int type;
 	BLI_stat_t st;
 
-	if (UTIL_DEBUG) printf("in getanimtype: %s\n", name);
+	BLI_assert(!BLI_path_is_rel(name));
+
+	if (UTIL_DEBUG) printf("%s: %s\n", __func__, name);
 
 #ifndef _WIN32
 #   ifdef WITH_QUICKTIME
@@ -434,7 +438,7 @@ int imb_get_anim_type(const char *name)
 bool IMB_isanim(const char *filename)
 {
 	int type;
-	
+
 	type = imb_get_anim_type(filename);
 	
 	return (type && type != ANIM_SEQUENCE);
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index 2f68880..28710fb 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -33,6 +33,10 @@
 
 
 #include <stdio.h>
+#include <stdlib.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_path_util.h"
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
@@ -50,6 +54,8 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
 {
 	const ImFileType *type;
 
+	BLI_assert(!BLI_path_is_rel(name));
+
 	if (ibuf == NULL) return (false);
 	ibuf->flags = flags;




More information about the Bf-blender-cvs mailing list