[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Lzip-bug] memcheck errors in lzip-1.2-pre2
From: |
Antonio Diaz Diaz |
Subject: |
Re: [Lzip-bug] memcheck errors in lzip-1.2-pre2 |
Date: |
Sat, 06 Dec 2008 02:13:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.11) Gecko/20050905 |
John Reiser wrote:
lzip-1.2-pre2 accesses memory outside of allocated regions.
Thank you again.
This patch solves it, but don't worry, tomorrow I'll replace it with
something more efficient. :-)
----------------------------------------------------------------
diff -urdN ../old_src/encoder.cc ./encoder.cc
--- ../old_src/encoder.cc 2008-09-21 12:35:33.000000000 +0200
+++ ./encoder.cc 2008-12-06 01:34:29.000000000 +0100
@@ -448,8 +448,18 @@
if( matchfinder.finished() ) { flush( state ); return true; }
if( fill_counter <= 0 ) { fill_distance_prices(); fill_counter =
512; }
- int ahead = best_pair_sequence( rep_distances, state );
- if( ahead <= 0 ) return false;
+ int ahead;
+ if( matchfinder.file_position() == 0 )
+ {
+ trials[0].dis = -1;
+ trials[0].price = ahead = 1;
+ if( !matchfinder.move_pos() ) return false;
+ }
+ else
+ {
+ ahead = best_pair_sequence( rep_distances, state );
+ if( ahead <= 0 ) return false;
+ }
fill_counter -= ahead;
for( int i = 0; ahead > 0; )
----------------------------------------------------------------
$ valgrind ./lzip -s23 foo
==26242== Memcheck, a memory error detector.
==26242== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==26242== Using LibVEX rev 1854, a library for dynamic binary translation.
==26242== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==26242== Using valgrind-3.3.1, a dynamic binary instrumentation framework.
==26242== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==26242== For more details, rerun with: -v
==26242==
==26242==
==26242== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==26242== malloc/free: in use at exit: 0 bytes in 0 blocks.
==26242== malloc/free: 15 allocs, 15 frees, 50,688,420 bytes allocated.
==26242== For counts of detected errors, rerun with: -v
==26242== All heap blocks were freed -- no leaks are possible.
Best regards,
Antonio.