winevt_c 0.4.0 → 0.4.1

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: 244a14b164c848b25d2aa5dbc75c5ccdbdb7af62424f37f6463d1be30b673484
4
- data.tar.gz: 954aa6d48fd5643d5992841f926c17b0b5c38790f6c1e9e9a4c37c2a2974c4ee
3
+ metadata.gz: 30a062502e07cec9555ad59177552ddfadcd9148a270637921d8e27f6ee5f9e6
4
+ data.tar.gz: 34aac8326a5a636c8ceee31770d569372d8975710cf46134f51f2848e512515e
5
5
  SHA512:
6
- metadata.gz: ac5be5abad00314ee60ec70c914ff53523eea1a918c17133fdde614d2638ddad9fab8f72dd9d57c492b467deaaf0c0c99b58a178b9b3dd072c42656ce93c8e3d
7
- data.tar.gz: 59a8a65f8a68c6548f46863e3b82345a5bb0f0a679a63c900e5dd29232940ab421f16b52c0859e1d87430202ca3797b84674b8b6b2cf8d5d3d96aa3bba6d69f8
6
+ metadata.gz: 5bc59bf70f5d06867c686caeae7c4d59135f6bd6e121c19d8b7665a026ce914278768de5b614548f3c86a35e216f8dea72ca0267bfb194a1d17d80759bcad899
7
+ data.tar.gz: b65a802022726202958c5c009f68fd941e569d60f4b6d9b0e539a7280b42fe3c732927a264e44681a9e5efae20b0bbb2018f26544961c63052e64cd6f86440d5
@@ -148,6 +148,8 @@ rb_winevt_query_render(VALUE self)
148
148
 
149
149
  utf8str = rb_utf8_str_new_cstr(result);
150
150
  free_allocated_mbstr(result);
151
+ if (wResult != NULL)
152
+ free(wResult);
151
153
 
152
154
  return utf8str;
153
155
  }
@@ -164,6 +164,8 @@ rb_winevt_subscribe_render(VALUE self)
164
164
 
165
165
  utf8str = rb_utf8_str_new_cstr(result);
166
166
  free_allocated_mbstr(result);
167
+ if (wResult != NULL)
168
+ free(wResult);
167
169
 
168
170
  return utf8str;
169
171
  }
@@ -69,7 +69,7 @@ WCHAR* render_event(EVT_HANDLE handle, DWORD flags)
69
69
  rb_raise(rb_eWinevtQueryError, "ErrorCode: %d\nError: %s\n", status, RSTRING_PTR(errmsg));
70
70
  }
71
71
 
72
- result = buffer;
72
+ result = _wcsdup(buffer);
73
73
 
74
74
  if (buffer)
75
75
  xfree(buffer);
@@ -214,6 +214,7 @@ VALUE get_values(EVT_HANDLE handle)
214
214
  result = wstr_to_mbstr(CP_UTF8, tmpWChar, -1);
215
215
  rb_ary_push(userValues, rb_utf8_str_new_cstr(result));
216
216
  free_allocated_mbstr(result);
217
+ CoTaskMemFree(tmpWChar);
217
218
  } else {
218
219
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
219
220
  }
@@ -253,6 +254,7 @@ VALUE get_values(EVT_HANDLE handle)
253
254
  result = wstr_to_mbstr(CP_UTF8, tmpWChar, -1);
254
255
  rb_ary_push(userValues, rb_utf8_str_new_cstr(result));
255
256
  free_allocated_mbstr(result);
257
+ LocalFree(tmpWChar);
256
258
  } else {
257
259
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
258
260
  }
@@ -300,6 +302,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
300
302
  LPVOID lpMsgBuf;
301
303
  WCHAR* prevBuffer;
302
304
  WCHAR *message;
305
+ WCHAR *reallocatedMessage;
303
306
 
304
307
  message = (WCHAR *)xmalloc(sizeof(WCHAR) * BUFSIZE);
305
308
  if (!EvtFormatMessage(hMetadata, handle, 0xffffffff, 0, NULL, EvtFormatMessageEvent, BUFSIZE, message, &bufferSizeNeeded)) {
@@ -328,7 +331,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
328
331
  MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
329
332
  (WCHAR *) &lpMsgBuf, 0, NULL);
330
333
 
331
- result = (WCHAR *)lpMsgBuf;
334
+ result = _wcsdup((WCHAR *)lpMsgBuf);
332
335
  LocalFree(lpMsgBuf);
333
336
 
334
337
  goto cleanup;
@@ -342,7 +345,11 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
342
345
 
343
346
  if (status == ERROR_INSUFFICIENT_BUFFER) {
344
347
  prevBuffer = message;
345
- message = (WCHAR *)realloc(prevBuffer, sizeof(WCHAR) * bufferSizeNeeded);
348
+ reallocatedMessage = (WCHAR *)realloc(prevBuffer, sizeof(WCHAR) * bufferSizeNeeded);
349
+ if (reallocatedMessage == NULL) {
350
+ rb_raise(rb_eWinevtQueryError, "Reallocation failed.");
351
+ }
352
+ message = reallocatedMessage;
346
353
 
347
354
  if(!EvtFormatMessage(hMetadata, handle, 0xffffffff, 0, NULL, EvtFormatMessageEvent, bufferSizeNeeded, message, &bufferSizeNeeded)) {
348
355
  status = GetLastError();
@@ -370,7 +377,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
370
377
  MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
371
378
  (WCHAR *) &lpMsgBuf, 0, NULL);
372
379
 
373
- result = (WCHAR *)lpMsgBuf;
380
+ result = _wcsdup((WCHAR *)lpMsgBuf);
374
381
  LocalFree(lpMsgBuf);
375
382
 
376
383
  goto cleanup;
@@ -382,7 +389,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
382
389
  }
383
390
  }
384
391
 
385
- result = message;
392
+ result = _wcsdup(message);
386
393
 
387
394
  cleanup:
388
395
 
@@ -450,7 +457,7 @@ WCHAR* get_description(EVT_HANDLE handle)
450
457
  goto cleanup;
451
458
  }
452
459
 
453
- result = get_message(hMetadata, handle);
460
+ result = _wcsdup(get_message(hMetadata, handle));
454
461
 
455
462
  #undef BUFSIZE
456
463
 
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winevt_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler