File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,11 +153,15 @@ __attribute__((noinline)) stat_t
153153sasjon_compute_stats(const simdjson::padded_string &p) {
154154 stat_t answer;
155155 char *buffer = (char *)malloc (p.size ());
156+ if (buffer == nullptr ) {
157+ return answer;
158+ }
156159 memcpy (buffer, p.data (), p.size ());
157160 auto d = sajson::parse (sajson::dynamic_allocation (),
158161 sajson::mutable_string_view (p.size (), buffer));
159162 answer.valid = d.is_valid ();
160163 if (!answer.valid ) {
164+ free (buffer);
161165 return answer;
162166 }
163167 answer.number_count = 0 ;
@@ -211,12 +215,16 @@ __attribute__((noinline)) stat_t
211215rapid_compute_stats(const simdjson::padded_string &p) {
212216 stat_t answer;
213217 char *buffer = (char *)malloc (p.size () + 1 );
218+ if (buffer == nullptr ) {
219+ return answer;
220+ }
214221 memcpy (buffer, p.data (), p.size ());
215222 buffer[p.size ()] = ' \0 ' ;
216223 rapidjson::Document d;
217224 d.ParseInsitu <kParseValidateEncodingFlag >(buffer);
218225 answer.valid = !d.HasParseError ();
219226 if (!answer.valid ) {
227+ free (buffer);
220228 return answer;
221229 }
222230 answer.number_count = 0 ;
You can’t perform that action at this time.
0 commit comments