For commands with with too few arguments, clear out args if it's an Array instead of replacing it with null in EvaluatorPreprocessor_read (issue 7804)
				
					
				
			For `PartialEvaluator_getTextContent`, the same `args` Array should be re-used for every `EvaluatorPreprocessor_read` call. Hence we want to ensure that it's not accidentally replaced with `null` in `EvaluatorPreprocessor_read`, since otherwise corrupt PDF files (with too few arguments for certain commands) will cause errors in `PartialEvaluator_getTextContent`. Perhaps a micro-optimization, but this patch also changes two `!args` comparisons to `args === null`, since that should be a tiny bit more efficient.
This commit is contained in:
		
							parent
							
								
									7f6a607ea5
								
							
						
					
					
						commit
						a930f9af15
					
				@ -2850,7 +2850,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
 | 
				
			|||||||
                argsLength--;
 | 
					                argsLength--;
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
              while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
 | 
					              while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
 | 
				
			||||||
                if (!args) {
 | 
					                if (args === null) {
 | 
				
			||||||
                  args = [];
 | 
					                  args = [];
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                args.unshift(nonProcessedArgs.pop());
 | 
					                args.unshift(nonProcessedArgs.pop());
 | 
				
			||||||
@ -2859,17 +2859,18 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (argsLength < numArgs) {
 | 
					            if (argsLength < numArgs) {
 | 
				
			||||||
              // If we receive too few args, it's not possible to possible
 | 
					              // If we receive too few arguments, it's not possible to execute
 | 
				
			||||||
              // to execute the command, so skip the command
 | 
					              // the command, hence we skip the command.
 | 
				
			||||||
              info('Command ' + fn + ': because expected ' +
 | 
					              warn('Skipping command ' + fn + ': expected ' + numArgs +
 | 
				
			||||||
                   numArgs + ' args, but received ' + argsLength +
 | 
					                   ' args, but received ' + argsLength + ' args.');
 | 
				
			||||||
                   ' args; skipping');
 | 
					              if (args !== null) {
 | 
				
			||||||
              args = null;
 | 
					                args.length = 0;
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
              continue;
 | 
					              continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          } else if (argsLength > numArgs) {
 | 
					          } else if (argsLength > numArgs) {
 | 
				
			||||||
            info('Command ' + fn + ': expected [0,' + numArgs +
 | 
					            info('Command ' + fn + ': expected [0,' + numArgs +
 | 
				
			||||||
                 '] args, but received ' + argsLength + ' args');
 | 
					                 '] args, but received ' + argsLength + ' args.');
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // TODO figure out how to type-check vararg functions
 | 
					          // TODO figure out how to type-check vararg functions
 | 
				
			||||||
@ -2884,7 +2885,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
          // argument
 | 
					          // argument
 | 
				
			||||||
          if (obj !== null) {
 | 
					          if (obj !== null) {
 | 
				
			||||||
            if (!args) {
 | 
					            if (args === null) {
 | 
				
			||||||
              args = [];
 | 
					              args = [];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            args.push(obj);
 | 
					            args.push(obj);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user