File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1358,8 +1358,8 @@ LLVMValueRef codegen_expr_cast(CodeGenContext *ctx, AstNode *node) {
13581358 // Integer to Pointer
13591359 if (source_kind == LLVMIntegerTypeKind &&
13601360 target_kind == LLVMPointerTypeKind ) {
1361- if (!target_type ) {
1362- fprintf (stderr , "Error: target_type is NULL in inttoptr cast\n" );
1361+ if (!target_type || ! LLVMTypeIsSized ( target_type ) ) {
1362+ fprintf (stderr , "Error: invalid pointer type in inttoptr cast\n" );
13631363 return NULL ;
13641364 }
13651365 return LLVMBuildIntToPtr (ctx -> builder , value , target_type , "inttoptr" );
@@ -1368,8 +1368,8 @@ LLVMValueRef codegen_expr_cast(CodeGenContext *ctx, AstNode *node) {
13681368 // Pointer to Integer
13691369 if (source_kind == LLVMPointerTypeKind &&
13701370 target_kind == LLVMIntegerTypeKind ) {
1371- if (!target_type ) {
1372- fprintf (stderr , "Error: target_type is NULL in ptrtoint cast\n" );
1371+ if (!target_type || ! LLVMTypeIsSized ( target_type ) ) {
1372+ fprintf (stderr , "Error: invalid integer type in ptrtoint cast\n" );
13731373 return NULL ;
13741374 }
13751375 return LLVMBuildPtrToInt (ctx -> builder , value , target_type , "ptrtoint" );
You can’t perform that action at this time.
0 commit comments