Ticket #3225: wseh.cpp.patch

File wseh.cpp.patch, 1.1 KB (added by kanetaka, 9 years ago)
  • source/lib/sysdep/os/win/wseh.cpp

     
    1 /* Copyright (c) 2010 Wildfire Games
     1/* Copyright (c) 2015 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
    44 * a copy of this software and associated documentation files (the
     
    370370{
    371371    if(argc == 0)
    372372        return EXIT_FAILURE;    // ensure &utf8_argv[0] is safe
     373
    373374    std::vector<char*> utf8_argv(argc);
     375    std::string buffer;
     376 
     377    char* p = (char*) 1;
    374378    for(int i = 0; i < argc; i++)
    375379    {
    376         std::string utf8 = utf8_from_wstring(argv[i]);
    377         utf8_argv[i] = strdup(utf8.c_str());
     380        buffer += "_" + utf8_from_wstring(argv[i]);
     381        *(&buffer.at(0) + (int)p - 1) = '\x0';
     382        utf8_argv[i] = p;
     383        p = (char*)buffer.length() + 1;
    378384    }
    379385
     386    p = &buffer.at(0);
     387    for (int i = 0; i < argc; i++)
     388        utf8_argv[i] = p + (int)utf8_argv[i];
     389
    380390    const int ret = main(argc, &utf8_argv[0]);
    381391
    382     for(int i = 0; i < argc; i++)
    383         free(utf8_argv[i]);
    384392    return ret;
    385393}
    386394