Mon, Dec 05, 2022 at 04:08:45PM +0100, Klaus Schmidinger wrote:
Instead if typecasting I guess I'll rather do it this way:
This worked as well.
If x2 ever becomes negative, something else must have gone wrong.
The actual culprit is cDvbSubtitleConverter::FinishPage(), which was invoking this code with NumAreas == 0 and a null pointer Areas. After I fixed that, the error went away, and Finnish DVB subtitles were still being displayed.
The first attached patch includes your suggested fixes and nothing that you opposed so far. The second attached patch fixes the following 2 issues. I agree that the NumCamSlots==0 case could be solved in a nicer way.
If (rows * pitch) is 0, nothing is copied.
On my test run, this code was not hit until the end, upon pressing the Setup button (which was followed by Right, OK, OK, to shut down VDR):
#7 0x00278908 in cGlyph::cGlyph (this=0xc6a798, CharCode=32, GlyphData=<optimized out>) at font.c:77 #8 0x0027b660 in cFreetypeFont::Glyph (this=this@entry=0xc91ea8, CharCode=3220926570, CharCode@entry=3322475946, AntiAliased=<optimized out>) at font.c:231 #9 0x0027c21c in cFreetypeFont::Width (s=<optimized out>, this=<optimized out>) at font.c:261 #10 cFreetypeFont::Width (this=0xc91ea8, s=<optimized out>) at font.c:248 #11 0x00584754 in cSkinLCARSDisplayMenu::SetTitle (this=0xc7a1e8, Title=0x5d9 <error: Cannot access memory at address 0x5d9>) at skinlcars.c:1559 #12 0x00407f4c in cOsdMenu::Display (this=0xc95178) at osdbase.c:244 #13 0x004137dc in cOsdMenu::AddSubMenu (this=this@entry=0xc13ef8, SubMenu=SubMenu@entry=0xc95178) at osdbase.c:521 #14 0x00357ca0 in cMenuMain::cMenuMain (this=0xc95db8, State=<optimized out>, OpenSubMenus=<optimized out>) at menu.c:4489 #15 0x0007c9f0 in main (argc=<optimized out>, argv=<optimized out>) at vdr.c:1276
I guess that the bitmap for character code 32 (space) is empty. I dug a bit further in another run to find the string in question:
#12 0x00407f2c in cOsdMenu::Display (this=0xc592c8) at osdbase.c:244 244 displayMenu->SetTitle(title); (gdb) p *this ..., title = 0xc68400 "Asetukset - VDR 2.6.2", ...
That is the title of the Setup menu in Finnish. I cannot imagine any other fix of this.
The font was DejaVuSans-Bold.ttf, in case it makes a difference.
If NumCamSlots is 0, SlotPriority[] is never accessed.
True, but as I noted in my other reply, the compiler is actually allowed to assume that it will be accessed, for the first iteration of the second loop. I did not check the generated code for any normal optimized build to see whether my compilers would actually apply that optimization.
#6 0x7679c26c in __ubsan_handle_vla_bound_not_positive () from /lib/arm-linux-gnueabihf/libubsan.so.1 #7 0x0016fb8c in cDevice::GetDevice (Channel=Channel@entry=0xbcb2a8, Priority=Priority@entry=0, LiveView=LiveView@entry=true, Query=Query@entry=false) at device.c:292 #8 0x0017e1e0 in cDevice::SetChannel (this=this@entry=0xbf5cf0, Channel=Channel@entry=0xbcb2a8, LiveView=LiveView@entry=125) at device.c:942 #9 0x0017fbb8 in cDevice::SwitchChannel (this=0xbf5cf0, Channel=0xbcb2a8, LiveView=LiveView@entry=true) at device.c:815 #10 0x000acfb8 in cChannels::SwitchTo ( this=this@entry=0xaa9044 cChannels::channels, Number=<optimized out>) at device.h:148 #11 0x0007991c in main (argc=<optimized out>, argv=<optimized out>) at vdr.c:918
Best regards,
Marko