1// Regression test for
2// https://code.google.com/p/address-sanitizer/issues/detail?id=274.
3
4// RUN: %clang_asan %s -framework Foundation -o %t
5// RUN: %run %t 2>&1 | FileCheck %s
6#import <Foundation/Foundation.h>
7
8#include <stdio.h>
9
10int main() {
11 NSString* version_file = @"MAJOR=35\n";
12 int major = 0, minor = 0, build = 0, patch = 0;
13 NSScanner* scanner = [NSScanner scannerWithString:version_file];
14 NSString *res = nil;
15 if ([scanner scanString:@"MAJOR=" intoString:nil] &&
16 [scanner scanInt:&major]) {
17 res = [NSString stringWithFormat:@"%d.%d.%d.%d",
18 major, minor, build, patch];
19 }
20 printf("%s\n", [res UTF8String]);
21 // CHECK: 35.0.0.0
22 return 0;
23}
24

source code of compiler-rt/test/asan/TestCases/Darwin/cstring_literals_regtest.mm