[Bf-committers] Patch 6395 Minor bug in source/blender/blenkernel/intern/material.c

Early Ehlinger early at respower.com
Wed Mar 21 19:05:46 CET 2007


Just yesterday I had a .blend file become corrupt using 2.43. Not sure 
exactly how that happened.

Anyway, when I tried to open the .blend, Blender would print a warning 
that some data had been lost and then crash. It was an access violation 
reading 0x0000000, which I believe translates to segfault on Linux.

So I fired up a debug build to see where it was happening.

Turns out, it was source/blender/blenkernel/intern/material.c, inside 
give_current_material( )

give_current_material() calls give_totcolp(), but doesn't check the 
result. In this case, presumably because the .blend file was somewhat 
corrupt, give_totcolp returned NULL, and give_current_material promptly 
dereferenced the pointer. WAMMO! Blender -> dead.

Anyway, here's a patch to simply propagate the NULL return from 
give_totcolp up the chain, which was enough to allow me to recover the 
rest of the information from the .blend file.

Unfortunately, I didn't think to keep the broken .blend to demonstrate 
the crash and the fix; I was so happy to have recovered it that I 
stupidly saved over the broken one with the recovered one.

-- Early Ehlinger, President, ResPower, Inc.


More information about the Bf-committers mailing list