Merge "Fix memory release issue in tts_parser_unload_config" into tizen
[platform/core/uifw/tts.git] / test / test_main.c
old mode 100644 (file)
new mode 100755 (executable)
index 428a356..1bcb001
@@ -41,10 +41,14 @@ static bool __tts_test_get_text_from_file(const char* path, char** text)
                return 0;
        }
 
-       fseek(fp , 0 , SEEK_END);
+       if (0 != fseek(fp , 0 , SEEK_END)) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to fseek()");
+               fclose(fp);
+               return 0;
+       }
 
        int text_len = ftell(fp);
-       if (0 >= text_len) {
+       if (0 >= text_len || 0 > text_len + 1) {
                SLOG(LOG_ERROR, tts_tag(), "File has no contents");
                fclose(fp);
                return 0;
@@ -53,7 +57,7 @@ static bool __tts_test_get_text_from_file(const char* path, char** text)
        rewind(fp);
 
        char* temp = NULL;
-       temp = (char*)calloc(1, text_len+1);
+       temp = (char*)calloc(1, text_len + 1);
 
        if (temp == NULL) {
                SLOG(LOG_ERROR, tts_tag(), "Fail to memory allocation");