Made base64_encode_block use a local variable for stepcount which is saved back to the struct before return
This commit is contained in:
		
							
								
								
									
										9
									
								
								external/libb64-1.2.1/src/cencode.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								external/libb64-1.2.1/src/cencode.c
									
									
									
									
										vendored
									
									
								
							@@ -26,6 +26,7 @@ char base64_encode_value(char value_in)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in)
 | 
					int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						int stepcount = state_in->stepcount;
 | 
				
			||||||
	const char* plainchar = plaintext_in;
 | 
						const char* plainchar = plaintext_in;
 | 
				
			||||||
	const char* const plaintextend = plaintext_in + length_in;
 | 
						const char* const plaintextend = plaintext_in + length_in;
 | 
				
			||||||
	char* codechar = code_out;
 | 
						char* codechar = code_out;
 | 
				
			||||||
@@ -42,6 +43,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
 | 
				
			|||||||
			if (plainchar == plaintextend)
 | 
								if (plainchar == plaintextend)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				state_in->step = step_A;
 | 
									state_in->step = step_A;
 | 
				
			||||||
 | 
									state_in->stepcount = stepcount;
 | 
				
			||||||
				state_in->result = result;
 | 
									state_in->result = result;
 | 
				
			||||||
				return codechar - code_out;
 | 
									return codechar - code_out;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -53,6 +55,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
 | 
				
			|||||||
			if (plainchar == plaintextend)
 | 
								if (plainchar == plaintextend)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				state_in->step = step_B;
 | 
									state_in->step = step_B;
 | 
				
			||||||
 | 
									state_in->stepcount = stepcount;
 | 
				
			||||||
				state_in->result = result;
 | 
									state_in->result = result;
 | 
				
			||||||
				return codechar - code_out;
 | 
									return codechar - code_out;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -64,6 +67,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
 | 
				
			|||||||
			if (plainchar == plaintextend)
 | 
								if (plainchar == plaintextend)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				state_in->step = step_C;
 | 
									state_in->step = step_C;
 | 
				
			||||||
 | 
									state_in->stepcount = stepcount;
 | 
				
			||||||
				state_in->result = result;
 | 
									state_in->result = result;
 | 
				
			||||||
				return codechar - code_out;
 | 
									return codechar - code_out;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -73,11 +77,10 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
 | 
				
			|||||||
			result  = (fragment & 0x03f) >> 0;
 | 
								result  = (fragment & 0x03f) >> 0;
 | 
				
			||||||
			*codechar++ = base64_encode_value(result);
 | 
								*codechar++ = base64_encode_value(result);
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			++(state_in->stepcount);
 | 
								if (++stepcount == CHARS_PER_LINE/4)
 | 
				
			||||||
			if (state_in->stepcount == CHARS_PER_LINE/4)
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				*codechar++ = '\n';
 | 
									*codechar++ = '\n';
 | 
				
			||||||
				state_in->stepcount = 0;
 | 
									stepcount = 0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user