mirror of
				https://github.com/isar/libmdbx.git
				synced 2025-10-31 15:38:57 +08:00 
			
		
		
		
	mdbx: fix div-by-zero while copy-with-compaction for non-resizeable DB.
Change-Id: Ice7f5675c3b2864195874f2e3c4ade9148cad048
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/core.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/core.c
									
									
									
									
									
								
							| @@ -15233,20 +15233,16 @@ done: | |||||||
|  |  | ||||||
| static __cold void compact_fixup_meta(MDBX_env *env, MDBX_meta *meta) { | static __cold void compact_fixup_meta(MDBX_env *env, MDBX_meta *meta) { | ||||||
|   /* Calculate filesize taking in account shrink/growing thresholds */ |   /* Calculate filesize taking in account shrink/growing thresholds */ | ||||||
|   if (meta->mm_geo.next > meta->mm_geo.now) { |   if (meta->mm_geo.next != meta->mm_geo.now) { | ||||||
|     const pgno_t aligned = pgno_align2os_pgno( |  | ||||||
|         env, |  | ||||||
|         pgno_add(meta->mm_geo.next, |  | ||||||
|                  meta->mm_geo.grow - meta->mm_geo.next % meta->mm_geo.grow)); |  | ||||||
|     meta->mm_geo.now = aligned; |  | ||||||
|   } else if (meta->mm_geo.next < meta->mm_geo.now) { |  | ||||||
|     meta->mm_geo.now = meta->mm_geo.next; |     meta->mm_geo.now = meta->mm_geo.next; | ||||||
|     const pgno_t aligner = |     const pgno_t aligner = | ||||||
|         meta->mm_geo.grow ? meta->mm_geo.grow : meta->mm_geo.shrink; |         meta->mm_geo.grow ? meta->mm_geo.grow : meta->mm_geo.shrink; | ||||||
|  |     if (aligner) { | ||||||
|       const pgno_t aligned = pgno_align2os_pgno( |       const pgno_t aligned = pgno_align2os_pgno( | ||||||
|           env, meta->mm_geo.next + aligner - meta->mm_geo.next % aligner); |           env, meta->mm_geo.next + aligner - meta->mm_geo.next % aligner); | ||||||
|       meta->mm_geo.now = aligned; |       meta->mm_geo.now = aligned; | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (meta->mm_geo.now < meta->mm_geo.lower) |   if (meta->mm_geo.now < meta->mm_geo.lower) | ||||||
|     meta->mm_geo.now = meta->mm_geo.lower; |     meta->mm_geo.now = meta->mm_geo.lower; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user