last_pos = EM_SAFE_STRLEN(*result_string);
new_buffer_length = last_pos + received_length + 1;
EM_DEBUG_LOG("new_buffer_length[%d]", new_buffer_length);
- *result_string = realloc(*result_string, new_buffer_length);
+
+ char *new_result_string = NULL;
+ new_result_string = realloc(*result_string, new_buffer_length);
+ if (NULL == new_result_string) {
+ EM_DEBUG_EXCEPTION("memory reallocation failed");
+ EM_SAFE_FREE(*result_string);
+ received_length = 0;
+ goto FINISH_OFF;
+ }
+
+ *result_string = new_result_string;
}
if (*result_string == NULL) {