<commit_before>//
// Created by valdemar on 14.10.17.
//

#include "Shader.h"

#include <glm/gtc/type_ptr.hpp>

#include <stdexcept>

namespace {

std::string load_file(const std::string &file_path) {
    FILE *fd = fopen(file_path.c_str(), "r");
    if (!fd) {
        char err_buf[512];
        sprintf(err_buf, "Load file(%s): %s", file_path.c_str(), strerror(errno));
        throw std::runtime_error(err_buf);
    }

    constexpr uint16_t CHUNK_SIZE = 256;
    char buf[CHUNK_SIZE];
    std::string content;
    while (size_t sz = fread(buf, 1, CHUNK_SIZE, fd)) {
        buf[sz] = '\0';
        content += buf;
    }
    return content;
}

bool validate_shader(GLuint shader) {<commit_msg>Fix buffer overflow<commit_after>//
// Created by valdemar on 14.10.17.
//

#include "Shader.h"

#include <glm/gtc/type_ptr.hpp>

#include <stdexcept>

namespace {

std::string load_file(const std::string &file_path) {
    FILE *fd = fopen(file_path.c_str(), "r");
    if (!fd) {
        char err_buf[512];
        sprintf(err_buf, "Load file(%s): %s", file_path.c_str(), strerror(errno));
        throw std::runtime_error(err_buf);
    }

    constexpr uint16_t CHUNK_SIZE = 256;
    char buf[CHUNK_SIZE + 1];
    std::string content;
    while (size_t sz = fread(buf, 1, CHUNK_SIZE, fd)) {
        buf[sz] = '\0';
        content += buf;
    }
    return content;
}

bool validate_shader(GLuint shader) {
{'fraction_non_alphanumeric': 0.15620542082738945, 'fraction_numerical': 0.023537803138373753, 'mean_word_length': 3.066666666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '318444', 'n_tokens_mistral': 550, 'n_tokens_neox': 532, 'n_words': 117}