@@ -772,6 +772,8 @@ static void FIO_adjustMemLimitForPatchFromMode(FIO_prefs_t* const prefs,
772
772
{
773
773
unsigned long long maxSize = MAX (prefs -> memLimit , MAX (dictSize , maxSrcFileSize ));
774
774
unsigned const maxWindowSize = (1U << ZSTD_WINDOWLOG_MAX );
775
+ if (maxSize == UTIL_FILESIZE_UNKNOWN )
776
+ EXM_THROW (42 , "Using --patch-from with stdin requires --stream-size" );
775
777
assert (maxSize != UTIL_FILESIZE_UNKNOWN );
776
778
if (maxSize > maxWindowSize )
777
779
EXM_THROW (42 , "Can't handle files larger than %u GB\n" , maxWindowSize /(1 GB ));
@@ -839,8 +841,10 @@ static cRess_t FIO_createCResources(FIO_prefs_t* const prefs,
839
841
840
842
/* need to update memLimit before calling createDictBuffer
841
843
* because of memLimit check inside it */
842
- if (prefs -> patchFromMode )
843
- FIO_adjustParamsForPatchFromMode (prefs , & comprParams , UTIL_getFileSize (dictFileName ), maxSrcFileSize , cLevel );
844
+ if (prefs -> patchFromMode ) {
845
+ unsigned long long const ssSize = (unsigned long long )prefs -> streamSrcSize ;
846
+ FIO_adjustParamsForPatchFromMode (prefs , & comprParams , UTIL_getFileSize (dictFileName ), ssSize > 0 ? ssSize : maxSrcFileSize , cLevel );
847
+ }
844
848
ress .dstBuffer = malloc (ress .dstBufferSize );
845
849
ress .dictBufferSize = FIO_createDictBuffer (& ress .dictBuffer , dictFileName , prefs ); /* works with dictFileName==NULL */
846
850
if (!ress .srcBuffer || !ress .dstBuffer )
0 commit comments