From 45441c07d4609493aecf265b64ad0c108722e9db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Apr 2010 09:12:18 +0000 Subject: various minor fixes - collada export would run MEM_freeN on an un-initialized pointer in some cases. - makesrna was missing a call to close a file. - text cursor update function was missing a NULL check for st->text. - possible (unlikely) un-initialized return value for bge python lamp.type, set error instead. - possible (unlikely) missing NULL terminator with strncpy for ffmpeg. --- source/blender/blenkernel/intern/writeffmpeg.c | 4 ++-- source/blender/editors/space_text/text_draw.c | 8 ++++---- source/blender/makesrna/intern/makesrna.c | 1 + source/blender/windowmanager/intern/wm_operators.c | 14 +++++--------- source/gameengine/Ketsji/KX_Light.cpp | 5 +++++ source/gameengine/Ketsji/KX_WorldIpoController.cpp | 3 ++- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ff6ebcc487f..a1cdced9074 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -382,7 +382,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop) fprintf(stderr, "FFMPEG expert option: %s: ", prop->name); - strncpy(name, prop->name, 128); + BLI_strncpy(name, prop->name, sizeof(name)); param = strchr(name, ':'); @@ -1078,7 +1078,7 @@ int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * s avcodec_get_context_defaults(&c); - strncpy(name_, str, 128); + strncpy(name_, str, sizeof(name_)); name = name_; while (*name == ' ') name++; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 4a73340d719..510429140d7 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1318,11 +1318,13 @@ void text_update_cursor_moved(bContext *C) { ScrArea *sa= CTX_wm_area(C); SpaceText *st= CTX_wm_space_text(C); - Text *text= st->text; + Text *text; ARegion *ar; int i, x, winx= 0; - if(!st) return; + if(!st || !st->text || st->text->curl) return; + + text= st->text; for(ar=sa->regionbase.first; ar; ar= ar->next) if(ar->regiontype==RGN_TYPE_WINDOW) @@ -1330,8 +1332,6 @@ void text_update_cursor_moved(bContext *C) winx -= TXT_SCROLL_WIDTH; - if(!text || !text->curl) return; - text_update_character_width(st); i= txt_get_span(text->lines.first, text->sell); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index fc019f6afe1..2914bc96a70 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -82,6 +82,7 @@ static int replace_if_different(char *tmpfile) if(fp_new==NULL) { /* shouldn't happen, just to be safe */ fprintf(stderr, "%s:%d, open error: \"%s\"\n", __FILE__, __LINE__, tmpfile); + fclose(fp_org); return -1; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index bd2263865c8..c6bab9e47e5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1871,19 +1871,15 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) #include "../../collada/collada.h" static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - char *path; - /* RNA_string_set(op->ptr, "path", "/tmp/test.dae"); */ - +{ if(!RNA_property_is_set(op->ptr, "path")) { - path = BLI_replacestr(G.sce, ".blend", ".dae"); + char *path = BLI_replacestr(G.sce, ".blend", ".dae"); RNA_string_set(op->ptr, "path", path); + MEM_freeN(path); } - + WM_event_add_fileselect(C, op); - - if (path) MEM_freeN(path); - + return OPERATOR_RUNNING_MODAL; } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index db708d25d40..109f248b15e 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -352,6 +352,11 @@ PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT } else if (!strcmp(type, "NORMAL")) { retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_NORMAL); } + else { + /* should never happen */ + PyErr_SetString(PyExc_TypeError, "light.type: internal error, invalid light type"); + retvalue = NULL; + } return retvalue; } diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.cpp b/source/gameengine/Ketsji/KX_WorldIpoController.cpp index f40c4b0253a..3404461d9e9 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.cpp +++ b/source/gameengine/Ketsji/KX_WorldIpoController.cpp @@ -48,7 +48,8 @@ bool KX_WorldIpoController::Update(double currentTime) for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { (*i)->Execute(m_ipotime);//currentTime); } - + + /* TODO, this will crash! */ KX_WorldInfo *world = NULL; if (m_modify_mist_start) { -- cgit v1.2.3