winevt_c 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 643bcdf4d5b8c420f73bbb333ff5f43d3aaa49fa5e5c5387f9b56b226a17a95b
4
- data.tar.gz: 3e1ac4f307bc238cc6fd3b6a1899d40d5906f73760fdab659a2b13155d4aeab0
3
+ metadata.gz: 8e35c2969b85874f8a795430b9ce36b6a8d7e6622ec5d9e3924d65ff3171095d
4
+ data.tar.gz: 0c7008c5273f506703f3a278c8c1404796a28e9933d29c025b587f2a07d1491a
5
5
  SHA512:
6
- metadata.gz: 14c3237a1fd9e278a1413a75736b75c4715daf9c4f58799bf1136784d3e9139a61a0eca41ba124ce5e740507cfc7a6bcb3c991cd31fd0b453ddcd263486aedf0
7
- data.tar.gz: 45562eefcdac2d2214233ee8633b01f0f2eedd258690fc37dbdfef0aaec7b6ca863f66665f499f1039bff25c8b07d327eaf2d444baad09cb85c8ccea5be9246d
6
+ metadata.gz: f8e2119e6de7b988a57d9ea04cb18370dbfaac84f1b2fe48b9fa44763bf7e73ed4ad8aa5458e970a21b0f054296a08c6835b118b58d5a4fb0b8c3c8903b237cd
7
+ data.tar.gz: 3f41be719b834e8aa0b72624f852e334e669974af0151f5ba83562b9bffaa4f997908f50de4b40426ce9298df17374f4ce1c394d858e39796ee6e0137b5e79d7
@@ -162,6 +162,9 @@ rb_winevt_query_message(VALUE self)
162
162
  wResult = get_description(winevtQuery->event);
163
163
  utf8str = wstr_to_rb_str(CP_UTF8, wResult, -1);
164
164
 
165
+ if (wResult != NULL)
166
+ free(wResult);
167
+
165
168
  return utf8str;
166
169
  }
167
170
 
@@ -177,6 +177,9 @@ rb_winevt_subscribe_message(VALUE self)
177
177
  wResult = get_description(winevtSubscribe->event);
178
178
  utf8str = wstr_to_rb_str(CP_UTF8, wResult, -1);
179
179
 
180
+ if (wResult != NULL)
181
+ free(wResult);
182
+
180
183
  return utf8str;
181
184
  }
182
185
 
@@ -23,9 +23,13 @@ void free_allocated_mbstr(const char* str)
23
23
  VALUE
24
24
  wstr_to_rb_str(UINT cp, const WCHAR *wstr, int clen)
25
25
  {
26
+ char *ptr;
26
27
  int len = WideCharToMultiByte(cp, 0, wstr, clen, nullptr, 0, nullptr, nullptr);
27
- VALUE str = rb_utf8_str_new(0, len);
28
- WideCharToMultiByte(cp, 0, wstr, clen, RSTRING_PTR(str), len, nullptr, nullptr);
28
+ if (!(ptr = static_cast<char *>(xmalloc(len)))) return rb_utf8_str_new_cstr("");
29
+ WideCharToMultiByte(cp, 0, wstr, clen, ptr, len, nullptr, nullptr);
30
+
31
+ VALUE str = rb_utf8_str_new_cstr(ptr);
32
+ xfree(ptr);
29
33
 
30
34
  return str;
31
35
  }
@@ -160,7 +164,7 @@ VALUE get_values(EVT_HANDLE handle)
160
164
  LARGE_INTEGER timestamp;
161
165
  SYSTEMTIME st;
162
166
  FILETIME ft;
163
- std::string strTime;
167
+ CHAR strTime[128];
164
168
  std::string sResult;
165
169
  VALUE rbObj;
166
170
 
@@ -247,11 +251,11 @@ VALUE get_values(EVT_HANDLE handle)
247
251
  ft.dwHighDateTime = timestamp.HighPart;
248
252
  ft.dwLowDateTime = timestamp.LowPart;
249
253
  if (FileTimeToSystemTime( &ft, &st )) {
250
- sprintf(&strTime[0], "%04d-%02d-%02d %02d:%02d:%02d.%dZ",
254
+ sprintf(strTime, "%04d-%02d-%02d %02d:%02d:%02d.%dZ",
251
255
  st.wYear , st.wMonth , st.wDay ,
252
256
  st.wHour , st.wMinute , st.wSecond,
253
257
  st.wMilliseconds);
254
- rb_ary_push(userValues, rb_utf8_str_new_cstr(strTime.c_str()));
258
+ rb_ary_push(userValues, rb_utf8_str_new_cstr(strTime));
255
259
  } else {
256
260
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
257
261
  }
@@ -259,11 +263,11 @@ VALUE get_values(EVT_HANDLE handle)
259
263
  case EvtVarTypeSysTime:
260
264
  if (pRenderedValues[i].SysTimeVal != nullptr) {
261
265
  st = *pRenderedValues[i].SysTimeVal;
262
- sprintf(&strTime[0], "%04d-%02d-%02d %02d:%02d:%02d.%dZ",
266
+ sprintf(strTime, "%04d-%02d-%02d %02d:%02d:%02d.%dZ",
263
267
  st.wYear , st.wMonth , st.wDay ,
264
268
  st.wHour , st.wMinute , st.wSecond,
265
269
  st.wMilliseconds);
266
- rb_ary_push(userValues, rb_utf8_str_new_cstr(strTime.c_str()));
270
+ rb_ary_push(userValues, rb_utf8_str_new_cstr(strTime));
267
271
  } else {
268
272
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
269
273
  }
@@ -471,5 +475,5 @@ cleanup:
471
475
  if (hMetadata)
472
476
  EvtClose(hMetadata);
473
477
 
474
- return const_cast<WCHAR *>(result.c_str());
478
+ return _wcsdup(result.c_str());
475
479
  }
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winevt_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake