Opened 16 years ago

Closed 16 years ago

Last modified 6 years ago

#8908 closed patch

Possible fix for Drascula's decodeRLE()

Reported by: eriktorbjorn Owned by: sev-
Priority: normal Component: Engine: Drascula
Version: Keywords:
Cc: Game: Drascula

Description

I noticed that Valgrind complains about invalid reads in decodeRLE() several times during the Drascula intro.

I think this happens when the inner loop ends with curByte being exactly 64000. Then the outer loop is run one extra time, which is where it reads outside the source buffer.

So this patch changes the condition to see if curByte >= 64000, but then of course the we have to write to dstPtr before breaking out of the loop. Otherwise, we might miss the last byte.

This wouldn't be a safe thing to do if the output buffer could ever be 0 bytes, but we know it's always 64000 bytes. I believe this is the correct fix, but I would appreciate it if someone else could take a look, too.

(I'm going to be out of town for a few days, so if it looks right, feel free to commit it.)

Ticket imported from: #2045543. Ticket imported from: patches/1013.

Attachments (1)

rle.diff (470 bytes ) - added by eriktorbjorn 16 years ago.
Patch against current SVN

Download all attachments as: .zip

Change History (4)

by eriktorbjorn, 16 years ago

Attachment: rle.diff added

Patch against current SVN

comment:1 by sev-, 16 years ago

Yes, it looks completely OK. Committed both to the trunk and branch.

comment:2 by sev-, 16 years ago

Status: newclosed

comment:3 by digitall, 6 years ago

Component: Engine: Drascula
Game: Drascula
Note: See TracTickets for help on using tickets.