theora_granule_time crash when built with encoder disabled
User appeared in the theora channel with a legit bug tonight. When libtheora is built with encoder_disabled, the internal encoder state is never set to null, so if it happens to be non-null due to garbage on the heap, a number of things break.
[22:31:40] <Andy_NJ> It's about a crash in theora_granule_time... [22:32:21] <Andy_NJ> In a newsgroup I found a short discussion on that, unfortunately the discussion ended without answering my problem... [22:33:06] {I don't know about the newsgroup, but keep going} [22:33:22] <Andy_NJ> There it was pointed out that theora_granule_time could crash because of the theora_state struct not beeing initialized properly [22:33:38] yes; you need to have successfully read the header for the function call to work. [22:34:00] <Andy_NJ> I think I've done that. [22:34:31] <Andy_NJ> The point is that when building the lib using encoder_disabled, the encoder part of the state get's not initizlied [22:35:21] [I wrote the original libtheora... three years ago; I'm unfamiliar with changes made since then, such as being able to build without the encoder] [22:35:41] let me have a quick look [22:37:58] <Andy_NJ> That would be great... [22:38:22] OK... reading the code, the call only depends on decode state, however... [22:38:39] this relies on encode state being nulled; it's possible that part isn;t happening (looking) [22:39:26] In fact, that looks like the problem. [22:41:06] at a guess, add the following line: [22:41:19] th->internal_encode = NULL; [22:41:30] after line 298 in lib/toplevel.c [22:42:18] if you can give that a try and see if it solves the problem, I'll submit a bug report/patch.
I have committed said patch; please sanity check
Monty