Skip to content

Commit c47ee65

Browse files
One More Stack To Heap Array Allocation
1 parent 8371618 commit c47ee65

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Source/Reai/Db.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,13 @@ Uint32 reai_db_get_model_id_for_model_name (ReaiDb* db, CString model_name) {
756756

757757
/* generate query */
758758
Size buf_size = snprintf (NULL, 0, query_fmtstr, model_name);
759-
Char query_buf[buf_size + 1];
760-
memset (query_buf, 0, buf_size + 1);
759+
Char* query_buf = ALLOCATE(Char, buf_size+1);
760+
761+
if(!query_buf) {
762+
PRINT_ERR(ERR_OUT_OF_MEMORY);
763+
return 0;
764+
}
765+
761766
snprintf (query_buf, buf_size, query_fmtstr, model_name);
762767

763768
/* compile sql */

0 commit comments

Comments
 (0)